matteo-ronchetti / torch-radon

Computational Tomography in PyTorch
https://torch-radon.readthedocs.io
GNU General Public License v3.0
219 stars 45 forks source link

NameError: name 'RaysCfg' is not defined #24

Closed liyues closed 3 years ago

liyues commented 3 years ago

Hi, I am trying to install the torch-radon library and came into this problem, although the installation process finished and didn't report any error. I follow the author's instructions in a closed issue and have some trials but didn't fix it.

1) I got the error "NameError: name 'RaysCfg' is not defined" when running Radon. 2) I follow the instruction as above and check "from torch_radon_cuda import RayCfg". The same issue came out: "ImportError: /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.27 not found". 3) I check the "ldd --version". It is "ldd (Ubuntu GLIBC 2.23-0ubuntu10) 2.23" which <2.27 as suggested. 4) I also try to install the new version by running "wget -qO- https://raw.githubusercontent.com/matteo-ronchetti/torch-radon/v2/auto_install.py | python - " as suggested, but the same errors aforementioned still remain. 5) I also try to compile the library from source. But the compilation is failed and the reported error is "nvcc fatal : Unsupported gpu architecture 'compute_70'".

I very much appreciate any help and suggestion that how this library could be installed and run successfully. Thanks!

matteo-ronchetti commented 3 years ago

Point 4 is surprising, seems like the new version of the library is not being installed. Please run pip uninstall torch-radon and then wget -qO- https://raw.githubusercontent.com/matteo-ronchetti/torch-radon/v2/auto_install.py | python -.

Regarding point 5 it seems like you have an old version of CUDA, you should still be able to compile the version in the v2 branch using these commands:

git clone https://github.com/matteo-ronchetti/torch-radon.git
cd torch-radon
git checkout v2
git pull
python make.py --local
python setup.py install
liyues commented 3 years ago

Thank you so much for your quick response!

I think the v2 version is installed. I try to uninstall and install it again as suggested but same errors remains.

The current CUDA version is 10.1. But when I try to compile the version v2, a new error just comes out:

  File "make.py", line 8, in <module>
    from ptx_annotation import annotate_ptx
  File "/torch-radon/ptx_annotation.py", line 2, in <module>
    from demangler import demangle
ModuleNotFoundError: No module named 'demangler'
matteo-ronchetti commented 3 years ago

Can you please report the full error?

Sorry, regarding the compilation I forgot to add that you should also run pip install -r dev_requirements.txt.

liyues commented 3 years ago

Thanks much for kind reminder! Sure, the full error reported when running command python make.py --local is as follows:

src/forward.cu(34): error: more than one instance of overloaded function "hypot" matches the argument list:
            function "hypot(float, float)"
            function "std::hypot(float, float)"
            argument types are: (float, float)
          detected during instantiation of "void radon_forward_cuda(const T *, const float *, T *, TextureCache &, const VolumeCfg &, const ProjectionCfg &, const ExecCfg &, int, int) [with T=float]" 
(177): here

src/forward.cu(90): error: more than one instance of overloaded function "hypot" matches the argument list:
            function "hypot(float, float)"
            function "std::hypot(float, float)"
            argument types are: (float, float)
          detected during instantiation of "void radon_forward_cuda(const T *, const float *, T *, TextureCache &, const VolumeCfg &, const ProjectionCfg &, const ExecCfg &, int, int) [with T=float]" 
(177): here

2 errors detected in the compilation of "/tmp/tmpxft_00006bcf_00000000-6_forward.cpp1.ii".
ERROR IN COMPILATION
liyues commented 3 years ago

Updates: the v2 library seems to work now after the following steps. 1) I still could not make it through by compiling the source code, so then get back to the precompiled installation. 2) make sure the cuda version of the current environment match the installed package. 3) update pytorch from 1.6.0 to 1.7.1 since v2 requires torch.fft 4) run installation command wget -qO- https://raw.githubusercontent.com/matteo-ronchetti/torch-radon/v2/auto_install.py | python -. 5) check the import torch_radon_cuda without any reported error. Check "from torch_radon_cuda import RaysCfg", there is still an error: ImportError: cannot import name 'RaysCfg' from 'torch_radon_cuda'. 6) from torch_radon import Radon works, and the FP and BP operations work well by testing on an example image, though there is a warning torch_radon/radon.py:270: DeprecationWarning: Radon() class is deprecated, use ParallelBeam instead.

Thanks a lot for your great help! Hope these information are useful.