CederGroupHub / chgnet

Pretrained universal neural network potential for charge-informed atomistic modeling https://chgnet.lbl.gov
https://doi.org/10.1038/s42256-023-00716-3
Other
215 stars 55 forks source link

[Bug]: `pip install chgnet` failed #160

Closed DanielYang59 closed 1 month ago

DanielYang59 commented 1 month ago

Version

v0.3.7

Which OS(es) are you using?

What happened?

pip install chgnet seems to fail for the latest v0.3.7 release, which also seems to impact the pymatgen CI: https://github.com/materialsproject/pymatgen/actions/runs/9350037332/job/25732649581?pr=3822

Code snippet

pip install chgnet

Log output

Building wheels for collected packages: chgnet, nvidia-ml-py3
  Building wheel for chgnet (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for chgnet (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [60 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.1-arm64-cpython-311
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet
      copying chgnet/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      copying chgnet/graph/graph.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      copying chgnet/graph/converter.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      copying chgnet/graph/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      copying chgnet/graph/crystalgraph.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/utils
      copying chgnet/utils/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/utils
      copying chgnet/utils/vasp_utils.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/utils
      copying chgnet/utils/common_utils.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/utils
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/basis.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/functions.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/encoders.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/model.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/composition_model.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/layers.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      copying chgnet/model/dynamics.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/model
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/data
      copying chgnet/data/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/data
      copying chgnet/data/dataset.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/data
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/trainer
      copying chgnet/trainer/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/trainer
      copying chgnet/trainer/trainer.py -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/trainer
      running egg_info
      writing chgnet.egg-info/PKG-INFO
      writing dependency_links to chgnet.egg-info/dependency_links.txt
      writing requirements to chgnet.egg-info/requires.txt
      writing top-level names to chgnet.egg-info/top_level.txt
      reading manifest file 'chgnet.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      writing manifest file 'chgnet.egg-info/SOURCES.txt'
      copying chgnet/graph/cygraph.pyx -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/graph
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.2.0
      copying chgnet/pretrained/0.2.0/README.md -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.2.0
      copying chgnet/pretrained/0.2.0/chgnet_0.2.0_e30f77s348m32.pth.tar -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.2.0
      creating build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.3.0
      copying chgnet/pretrained/0.3.0/README.md -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.3.0
      copying chgnet/pretrained/0.3.0/chgnet_0.3.0_e29f68s314m37.pth.tar -> build/lib.macosx-11.1-arm64-cpython-311/chgnet/pretrained/0.3.0
      running build_ext
      Compiling chgnet/graph/cygraph.pyx because it changed.
      [1/1] Cythonizing chgnet/graph/cygraph.pyx
      building 'chgnet.graph.cygraph' extension
      creating build/temp.macosx-11.1-arm64-cpython-311
      creating build/temp.macosx-11.1-arm64-cpython-311/chgnet
      creating build/temp.macosx-11.1-arm64-cpython-311/chgnet/graph
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/anaconda3/include -arch arm64 -fPIC -O2 -isystem /opt/anaconda3/include -arch arm64 -I/opt/anaconda3/include/python3.11 -c chgnet/graph/cygraph.c -o build/temp.macosx-11.1-arm64-cpython-311/chgnet/graph/cygraph.o
      chgnet/graph/cygraph.c:1238:10: fatal error: 'fast_converter_libraries/create_graph.c' file not found
      #include "fast_converter_libraries/create_graph.c"
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for chgnet
  Building wheel for nvidia-ml-py3 (setup.py) ... done
  Created wheel for nvidia-ml-py3: filename=nvidia_ml_py3-7.352.0-py3-none-any.whl size=19172 sha256=390a142b23fbf3b4250902e0cd4810b5670230854a2c459a82b8ecd5c2d2a0a2
  Stored in directory: /Users/yang/Library/Caches/pip/wheels/47/50/9e/29dc79037d74c3c1bb4a8661fb608e8674b7e4260d6a3f8f51
Successfully built nvidia-ml-py3
Failed to build chgnet
ERROR: Could not build wheels for chgnet, which is required to install pyproject.toml-based projects

Code of Conduct

janosh commented 1 month ago

yeah i noticed that as well. haven't had time to look into it yet. if anyone wants to debug, that'd be great! first place i would look is the last run for release.yml. seems like all the wheels were built correctly so not sure why pip install chgnet in PMG CI even needs to recompile.

DanielYang59 commented 1 month ago

not sure why pip install chgnet in PMG CI even needs to recompile.

pip install chgnet on my Mac machine seems to recompile as well

I noticed the fast_converter_libraries/create_graph.c is indeed missing under chgnet.graph (and the same for 0.3.5, so this might not be the reason?) :

(venv) yang@Yang-MacBook graph % pwd
/Users/yang/developer/chgnet/dist/chgnet-0.3.7/chgnet/graph
(venv) yang@Yang-MacBook graph % ls
__init__.py     converter.py    crystalgraph.py cygraph.c       cygraph.pyx     graph.py

Can recreate this locally with:

python setup.py sdist
pip install dist/chgnet-0.3.7.tar.gz
naji-usr commented 1 month ago

Same problem with pip install chgnet on MacOS (M3 Chip, MacOS 14.5). Any help with that will be great!

arshad880 commented 1 month ago

I use CHGNet on google colab and its been having issues since Sunday, any way out?

janosh commented 1 month ago

@arshad880 please use pip install chgnet==0.3.5 until we release a fix

arshad880 commented 1 month ago

@janosh Thank you so much, it works.

DanielYang59 commented 1 month ago

seems like all the wheels were built correctly so not sure why pip install chgnet in PMG CI even needs to recompile.

Yes the wheels seem built correctly but they are not uploaded to PyPI, only the source distribution is there.

For 0.3.5, however, wheels are available, so I assume there must be something wrong with uploading the wheels to PyPI (release action for 0.3.5 for comparison)

Perhaps it's good to double check the .github/workflows/release.yml (I don't have much experience with this, so looking forward to your analysis :) )?

janosh commented 1 month ago

@DanielYang59 thanks for looking into this, that pinpoints the issue to the artifact download step.

https://github.com/CederGroupHub/chgnet/blob/10254d356a74c917941d289f9f39ece5cadeb9bd/.github/workflows/release.yml#L74-L80

it only finds the source distribution which is named artifact.zip but not the compiled wheels which are named

https://github.com/CederGroupHub/chgnet/blob/6c2e48fb40c64e4257dbbd5b266119b4725627f1/.github/workflows/release.yml#L64

i'll try to fix this in #161

DanielYang59 commented 1 month ago

@janosh Thanks for letting me know and the fix :)

DanielYang59 commented 1 month ago

Seems v0.3.8 is working properly now, thanks for the fix :)