LLNL / LEAP

comprehensive library of 3D transmission Computed Tomography (CT) algorithms with Python API and fully integrated with PyTorch
https://leapct.readthedocs.io
MIT License
74 stars 8 forks source link

import leaptorch error #16

Closed junbopeng closed 5 months ago

junbopeng commented 5 months ago

leapctype.py", line 149, in create_new_model self.libprojectors.create_new_model.restype = ctypes.c_int AttributeError: 'NoneType' object has no attribute 'create_new_model'

kylechampley commented 5 months ago

My best guess is that the install failed. Could you send me the full traceback?

junbopeng commented 5 months ago

My best guess is that the install failed. Could you send me the full traceback?

I followed the instructions here.


import leaptorch Error: could not find LEAP dynamic library at /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/libleap.so or /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/../build/lib/libleap.so Traceback (most recent call last): File "", line 1, in File "/home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/leaptorch.py", line 13, in lct = tomographicModels() File "/home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/leapctype.py", line 137, in init self.param_id = self.create_new_model() File "/home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/leapctype.py", line 149, in create_new_model self.libprojectors.create_new_model.restype = ctypes.c_int AttributeError: 'NoneType' object has no attribute 'create_new_model'

And the leapctype could be imported.

kylechampley commented 5 months ago

Yep, it looks like dynamic library failed to compile. A couple of things to check 1) Do you have all the dependencies met? They are listed here: https://github.com/LLNL/LEAP/wiki/Installing-and-Using-LEAP 2) Trying running the following command which should print out all the compilation errors: pip install -v . 3) I precompiled the dynamic libraries for version 1.0, you can just download them here: https://github.com/LLNL/LEAP/releases 4) One common error in the compilation is a CMake error. A change that helped another user is listed here: https://github.com/LLNL/LEAP/issues/9#issuecomment-1881344355

junbopeng commented 5 months ago

Yep, it looks like dynamic library failed to compile. A couple of things to check

  1. Do you have all the dependencies met? They are listed here: https://github.com/LLNL/LEAP/wiki/Installing-and-Using-LEAP
  2. Trying running the following command which should print out all the compilation errors: pip install -v .
  3. I precompiled the dynamic libraries for version 1.0, you can just download them here: https://github.com/LLNL/LEAP/releases
  4. One common error in the compilation is a CMake error. A change that helped another user is listed here: encountered an error while running the demo #9 (comment)

I reinstalled the leap and encountered the same error in import leaptorch.

It seems that the installation is complete:

(py39) jp_peng@sn4622118213:~/Documents/DECBCT_unsup/LEAP$ pip install -v . Using pip 23.3.1 from /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/pip (python 3.9) Processing /home/jp_peng/Documents/DECBCT_unsup/LEAP Running command python setup.py egg_info ./etc/build.sh: 13: cmake: not found /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/setuptools/dist.py:498: SetuptoolsDeprecationWarning: Invalid dash-separated options !!

      ********************************************************************************
      Usage of dash-separated 'description-file' will not be supported in future
      versions. Please use the underscore name 'description_file' instead.

      This deprecation is overdue, please update your project and remove deprecated
      calls to avoid build errors in the future.

      See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
      ********************************************************************************

!! opt = self.warn_dash_deprecation(opt, section) running egg_info creating /tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info writing /tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/dependency_links.txt writing requirements to /tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/requires.txt writing top-level names to /tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/SOURCES.txt' writing manifest file '/tmp/pip-pip-egg-info-96dd29l4/leapct.egg-info/SOURCES.txt' Preparing metadata (setup.py) ... done Requirement already satisfied: numpy in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from leapct==1.0) (1.26.3) Requirement already satisfied: torch in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from leapct==1.0) (2.1.2) Requirement already satisfied: filelock in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (3.13.1) Requirement already satisfied: typing-extensions in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (4.9.0) Requirement already satisfied: sympy in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (1.12) Requirement already satisfied: networkx in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (3.1) Requirement already satisfied: jinja2 in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (3.1.2) Requirement already satisfied: fsspec in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from torch->leapct==1.0) (2023.12.2) Requirement already satisfied: MarkupSafe>=2.0 in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from jinja2->torch->leapct==1.0) (2.1.3) Requirement already satisfied: mpmath>=0.19 in /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages (from sympy->torch->leapct==1.0) (1.3.0) Building wheels for collected packages: leapct Running command python setup.py bdist_wheel ./etc/build.sh: 13: cmake: not found /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/setuptools/dist.py:498: SetuptoolsDeprecationWarning: Invalid dash-separated options !!

      ********************************************************************************
      Usage of dash-separated 'description-file' will not be supported in future
      versions. Please use the underscore name 'description_file' instead.

      This deprecation is overdue, please update your project and remove deprecated
      calls to avoid build errors in the future.

      See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
      ********************************************************************************

!! opt = self.warn_dash_deprecation(opt, section) running bdist_wheel running build running build_py creating build/lib copying src/leaptorch.py -> build/lib copying src/leapctype.py -> build/lib /home/jp_peng/.conda/envs/py39/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !!

      ********************************************************************************
      Please avoid running ``setup.py`` directly.
      Instead, use pypa/build, pypa/installer or other
      standards-based tools.

      See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
      ********************************************************************************

!! self.initialize_options() installing to build/bdist.linux-x86_64/wheel running install running install_lib creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/wheel copying build/lib/leapctype.py -> build/bdist.linux-x86_64/wheel copying build/lib/leaptorch.py -> build/bdist.linux-x86_64/wheel running install_egg_info running egg_info creating src/leapct.egg-info writing src/leapct.egg-info/PKG-INFO writing dependency_links to src/leapct.egg-info/dependency_links.txt writing requirements to src/leapct.egg-info/requires.txt writing top-level names to src/leapct.egg-info/top_level.txt writing manifest file 'src/leapct.egg-info/SOURCES.txt' reading manifest file 'src/leapct.egg-info/SOURCES.txt' writing manifest file 'src/leapct.egg-info/SOURCES.txt' Copying src/leapct.egg-info to build/bdist.linux-x86_64/wheel/leapct-1.0-py3.9.egg-info running install_scripts creating build/bdist.linux-x86_64/wheel/leapct-1.0.dist-info/WHEEL creating '/tmp/pip-wheel-bqy16jhg/leapct-1.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it adding 'leapctype.py' adding 'leaptorch.py' adding 'leapct-1.0.dist-info/METADATA' adding 'leapct-1.0.dist-info/WHEEL' adding 'leapct-1.0.dist-info/top_level.txt' adding 'leapct-1.0.dist-info/RECORD' removing build/bdist.linux-x86_64/wheel Building wheel for leapct (setup.py) ... done Created wheel for leapct: filename=leapct-1.0-py3-none-any.whl size=27450 sha256=07f591e9b39a67899ee488b51c5ddf5241af41d4205d4b2651735f4b242e8cbc Stored in directory: /tmp/pip-ephem-wheel-cache-8vgl3igw/wheels/0e/f9/1b/fe1249fe8768085c66444dc1f522370c4ea10bfba6fd055a76 Successfully built leapct Installing collected packages: leapct Successfully installed leapct-1.0

kylechampley commented 5 months ago

Unfortunately, it always says "Successfully installed leapct..." even though it is not successful.

Anyway, if you look at the output you posted you can see that it says "./etc/build.sh: 13: cmake: not found"

For some reason your system cannot find cmake. This is what is causing your issues and you'll have to resolve this. Again, you can always use the precompiled library if you are still having trouble.

junbopeng commented 5 months ago

Unfortunately, it always says "Successfully installed leapct..." even though it is not successful.

Anyway, if you look at the output you posted you can see that it says "./etc/build.sh: 13: cmake: not found"

For some reason your system cannot find cmake. This is what is causing your issues and you'll have to resolve this. Again, you can always use the precompiled library if you are still having trouble.

Thanks for your help! I reinstalled cmake and leapct, seems working now.