kyonofx / MDsim

[TMLR 2023] Training and simulating MD with ML force fields

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Torch Sparse Error when running examples

hongshuh opened this issue · comments

I was following the README instructions for Installating the enviroments, but I encountered an error message when running the code.

python simulate.py --config_yml configs/simulate/water.yml --model_dir example_model/water_1k_schnet

I got a error with following message:

Traceback (most recent call last):
  File "/home/hongshuh/MDsim/simulate.py", line 28, in <module>
    from mdsim.md.ase_utils import data_to_atoms, OCPCalculator, Simulator
  File "/home/hongshuh/MDsim/mdsim/md/ase_utils.py", line 8, in <module>
    from torch_geometric.data import Data
  File "/home/hongshuh/.local/lib/python3.9/site-packages/torch_geometric/__init__.py", line 4, in <module>
    import torch_geometric.data
  File "/home/hongshuh/.local/lib/python3.9/site-packages/torch_geometric/data/__init__.py", line 1, in <module>
    from .data import Data
  File "/home/hongshuh/.local/lib/python3.9/site-packages/torch_geometric/data/data.py", line 18, in <module>
    from torch_sparse import SparseTensor
  File "/home/hongshuh/anaconda3/envs/mdsim/lib/python3.9/site-packages/torch_sparse/__init__.py", line 40, in <module>
    from .tensor import SparseTensor  # noqa
  File "/home/hongshuh/anaconda3/envs/mdsim/lib/python3.9/site-packages/torch_sparse/tensor.py", line 13, in <module>
    class SparseTensor(object):
  File "/home/hongshuh/anaconda3/envs/mdsim/lib/python3.9/site-packages/torch/jit/_script.py", line 1302, in script
    _compile_and_register_class(obj, _rcb, qualified_name)
  File "/home/hongshuh/anaconda3/envs/mdsim/lib/python3.9/site-packages/torch/jit/_recursive.py", line 44, in _compile_and_register_class
    script_class = torch._C._jit_script_class_compile(qualified_name, ast, defaults, rcb)
RuntimeError: 
object has no attribute sparse_csc_tensor:
  File "/home/hongshuh/anaconda3/envs/mdsim/lib/python3.9/site-packages/torch_sparse/tensor.py", line 520
            value = torch.ones(self.nnz(), dtype=dtype, device=self.device())
    
        return torch.sparse_csc_tensor(colptr, row, value, self.sizes())
               ~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
commented

this is likely due to incorrect versions of PyG or torch_sparse. Could you make sure you installed the same versions as in README?

this is likely due to incorrect versions of PyG or torch_sparse. Could you make sure you installed the same versions as in README?

I just copied the comman from README, It should be the same version, Can you upload a enviroment.yml file?

I have the same issue. A conda environment will be more helpful.

commented

The procedure in README was tested. Here is an export of my working environment:

name: mdsim
channels:
  - https://conda.deepmodeling.com
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - abseil-cpp=20210324.2=h2531618_0
  - absl-py=1.0.0=pyh7a5ff2f_0
  - aiohttp=3.8.1=py39h7f8727e_1
  - aiosignal=1.2.0=pyhd3eb1b0_0
  - argon2-cffi=21.3.0=pyhd3eb1b0_0
  - argon2-cffi-bindings=21.2.0=py39h7f8727e_0
  - astunparse=1.6.3=py_0
  - async-timeout=4.0.2=py39h06a4308_0
  - attrs=21.4.0=pyhd3eb1b0_0
  - backcall=0.2.0=pyhd3eb1b0_0
  - backrefs=5.0.1=pyhd8ed1ab_0
  - beautifulsoup4=4.11.1=py39h06a4308_0
  - blas=1.0=mkl
  - bleach=4.1.0=pyhd3eb1b0_0
  - blinker=1.4=py39h06a4308_0
  - bracex=2.1.1=pyhd8ed1ab_0
  - brotlipy=0.7.0=py39h27cfd23_1003
  - c-ares=1.18.1=h7f8727e_0
  - ca-certificates=2022.07.19=h06a4308_0
  - cachetools=4.2.2=pyhd3eb1b0_0
  - certifi=2022.9.24=py39h06a4308_0
  - cffi=1.15.1=py39h74dc2b5_0
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - click=8.0.4=py39h06a4308_0
  - cloudpickle=2.0.0=pyhd3eb1b0_0
  - cryptography=37.0.1=py39h9ce1e76_0
  - cudatoolkit=11.3.1=h2bc3f7f_2
  - cudnn=8.2.1=cuda11.3_0
  - dargs=0.2.6=pyh7a5ff2f_0
  - dataclasses=0.8=pyh6d0b6a4_7
  - decorator=5.1.1=pyhd3eb1b0_0
  - deepmd-kit=2.1.0=py39_0_cuda11.3_gpu
  - defusedxml=0.7.1=pyhd3eb1b0_0
  - entrypoints=0.4=py39h06a4308_0
  - fftw=3.3.9=h27cfd23_1
  - frozenlist=1.2.0=py39h7f8727e_0
  - gast=0.4.0=pyhd3eb1b0_0
  - giflib=5.2.1=h7b6447c_0
  - google-auth=2.6.0=pyhd3eb1b0_0
  - google-auth-oauthlib=0.4.1=py_2
  - google-pasta=0.2.0=pyhd3eb1b0_0
  - grpcio=1.42.0=py39hce63b2e_0
  - gsl=2.7.1=h6e86dc7_1
  - h5py=3.7.0=py39h737f45e_0
  - hdf5=1.10.6=hb1b8bf9_0
  - horovod=0.24.1=py39h9622761_0
  - icu=68.1=h2531618_0
  - idna=3.3=pyhd3eb1b0_0
  - importlib-metadata=4.11.3=py39h06a4308_0
  - intel-openmp=2021.4.0=h06a4308_3561
  - ipython_genutils=0.2.0=pyhd3eb1b0_1
  - jedi=0.18.1=py39h06a4308_1
  - jpeg=9e=h7f8727e_0
  - jsoncpp=1.9.4=hff7bd54_2
  - jsonschema=4.16.0=py39h06a4308_0
  - jupyter_client=7.3.5=py39h06a4308_0
  - jupyter_core=4.11.1=py39h06a4308_0
  - jupyterlab_pygments=0.1.2=py_0
  - jupyterlab_widgets=1.0.0=pyhd3eb1b0_1
  - keras=2.7.0=pyh7a5ff2f_0
  - keras-preprocessing=1.1.2=pyhd3eb1b0_0
  - krb5=1.19.2=hac12032_0
  - lammps=20220623.1=h9954876_1
  - ld_impl_linux-64=2.38=h1181459_1
  - libcurl=7.84.0=h91b91d3_0
  - libdeepmd=2.1.0=0_cuda11.3_gpu
  - libedit=3.1.20210910=h7f8727e_0
  - libev=4.33=h7f8727e_1
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgfortran-ng=7.5.0=ha8ba4b0_17
  - libgfortran4=7.5.0=ha8ba4b0_17
  - libgomp=11.2.0=h1234567_1
  - libnghttp2=1.46.0=hce63b2e_0
  - libopenblas=0.3.18=hf726d26_0
  - libpng=1.6.37=hbc83047_0
  - libprotobuf=3.14.0=h8c45485_0
  - libsodium=1.0.18=h7b6447c_0
  - libssh2=1.10.0=h8f2d780_0
  - libstdcxx-ng=11.2.0=h1234567_1
  - libtensorflow_cc=2.7.0=cuda113hbf71e95_1
  - markdown=3.3.4=py39h06a4308_0
  - markupsafe=2.1.1=py39h7f8727e_0
  - matplotlib-inline=0.1.6=py39h06a4308_0
  - mistune=0.8.4=py39h27cfd23_1000
  - mkl=2021.4.0=h06a4308_640
  - mkl-service=2.4.0=py39h7f8727e_0
  - mkl_fft=1.3.1=py39hd3c417c_0
  - mkl_random=1.2.2=py39h51133e4_0
  - mpi=1.0=mpich
  - mpi4py=3.1.3=py39h21fafdc_1
  - mpich=3.3.2=hc856adb_0
  - multidict=5.2.0=py39h5eee18b_3
  - nbclient=0.5.13=py39h06a4308_0
  - nbconvert=6.4.4=py39h06a4308_0
  - nbformat=5.5.0=py39h06a4308_0
  - nccl=2.11.4.1=h83d496c_1
  - ncurses=6.3=h5eee18b_3
  - notebook=6.4.12=py39h06a4308_0
  - numpy=1.23.1=py39h6c91a56_0
  - numpy-base=1.23.1=py39ha15fc14_0
  - oauthlib=3.2.0=pyh7a5ff2f_0
  - openssl=1.1.1q=h7f8727e_0
  - opt_einsum=3.3.0=pyhd3eb1b0_1
  - packaging=21.3=pyhd3eb1b0_0
  - pandocfilters=1.5.0=pyhd3eb1b0_0
  - parso=0.8.3=pyhd3eb1b0_0
  - pexpect=4.8.0=pyhd3eb1b0_3
  - pickleshare=0.7.5=pyhd3eb1b0_1003
  - pip=22.2.2=py39h06a4308_0
  - plumed=2.8.0=h5980d18_1
  - prometheus_client=0.14.1=py39h06a4308_0
  - protobuf=3.14.0=py39h2531618_1
  - psutil=5.9.0=py39h5eee18b_0
  - ptyprocess=0.7.0=pyhd3eb1b0_2
  - pure_eval=0.2.2=pyhd3eb1b0_0
  - pyasn1=0.4.8=pyhd3eb1b0_0
  - pyasn1-modules=0.2.8=py_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pyjwt=2.4.0=pyh7a5ff2f_0
  - pylammps=20220623.1=pyh29e1a88_1
  - pyopenssl=22.0.0=pyhd3eb1b0_0
  - pyparsing=3.0.9=py39h06a4308_0
  - pyrsistent=0.18.0=py39heee7806_0
  - pysocks=1.7.1=py39h06a4308_0
  - python=3.9.11=h12debd9_2
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - python-fastjsonschema=2.16.2=py39h06a4308_0
  - python-flatbuffers=2.0=pyhd3eb1b0_0
  - python-hostlist=1.21=pyh9f0ad1d_0
  - pyyaml=6.0=py39h7f8727e_1
  - readline=8.1.2=h7f8727e_1
  - requests=2.28.1=py39h06a4308_0
  - requests-oauthlib=1.3.0=py_0
  - rsa=4.7.2=pyhd3eb1b0_1
  - scipy=1.7.1=py39h292c36d_2
  - send2trash=1.8.0=pyhd3eb1b0_1
  - setuptools=63.4.1=py39h06a4308_0
  - six=1.16.0=pyhd3eb1b0_1
  - snappy=1.1.9=h295c915_0
  - soupsieve=2.3.1=pyhd3eb1b0_0
  - sqlite=3.39.3=h5082296_0
  - stack_data=0.2.0=pyhd3eb1b0_0
  - tensorboard=2.6.0=py_1
  - tensorboard-data-server=0.6.0=py39hca6d32c_0
  - tensorboard-plugin-wit=1.8.1=py39h06a4308_0
  - tensorflow=2.7.0=cuda113py39h5fe7361_0
  - tensorflow-estimator=2.7.0=cuda113py39h64e3112_0
  - tensorflow-io-gcs-filesystem=999999=placeholder
  - termcolor=1.1.0=py39h06a4308_1
  - terminado=0.13.1=py39h06a4308_0
  - testpath=0.6.0=py39h06a4308_0
  - tk=8.6.12=h1ccaba5_0
  - tornado=6.2=py39h5eee18b_0
  - typing-extensions=4.3.0=py39h06a4308_0
  - typing_extensions=4.3.0=py39h06a4308_0
  - tzdata=2022c=h04d1e81_0
  - urllib3=1.26.11=py39h06a4308_0
  - wcmatch=8.2=pyhd8ed1ab_0
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - webencodings=0.5.1=py39h06a4308_1
  - werkzeug=2.0.3=pyhd3eb1b0_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - wrapt=1.14.1=py39h5eee18b_0
  - xz=5.2.6=h5eee18b_0
  - yaml=0.2.5=h7b6447c_0
  - yarl=1.8.1=py39h5eee18b_0
  - zeromq=4.3.4=h2531618_0
  - zipp=3.8.0=py39h06a4308_0
  - zlib=1.2.12=h5eee18b_3
  - pip:
    - asttokens==2.0.8
    - debugpy==1.6.3
    - executing==1.1.1
    - ipykernel==6.16.0
    - ipython==8.5.0
    - ipywidgets==8.0.2
    - jinja2==3.1.2
    - jupyter-client==7.4.2
    - jupyterlab-widgets==3.0.3
    - nest-asyncio==1.5.6
    - nglview==3.0.1
    - prompt-toolkit==3.0.31
    - pyg-nightly==2.0.5.dev20220418
    - pygments==2.13.0
    - pyzmq==24.0.1
    - stack-data==0.5.1
    - torch==1.11.0+cu113
    - torch-cluster==1.6.0
    - torch-scatter==2.0.9
    - torch-sparse==0.6.15
    - torch-spline-conv==1.2.1
    - torchaudio==0.11.0+cu113
    - torchvision==0.12.0+cu113
    - traitlets==5.4.0
    - widgetsnbextension==4.0.3

It's most likely the version of torch-sparse. Try the torch-sparse==0.6.14.

Closing this now, feel free to reopen if problems remain.