Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name '_C' from partially initialized module 'torchsdf' (most likely due to a circular import) #1

Open
ccmCCMfk opened this issue Mar 29, 2023 · 5 comments

Comments

@ccmCCMfk
Copy link

Traceback (most recent call last):
File "setup.py", line 176, in
ext_modules=get_extensions(),
File "setup.py", line 135, in get_extensions
include_dirs = get_include_dirs()
File "setup.py", line 160, in get_include_dirs
_, bare_metal_major, _ = get_cuda_bare_metal_version(CUDA_HOME)
File "setup.py", line 59, in get_cuda_bare_metal_version
raw_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"], universal_newlines=True)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Traceback (most recent call last):
File "", line 1, in
File "/home/ustc/PycharmProjects/DexGraspNet/TorchSDF/torchsdf/init.py", line 1, in
from torchsdf.sdf import *
File "/home/ustc/PycharmProjects/DexGraspNet/TorchSDF/torchsdf/sdf.py", line 2, in
from torchsdf import _C
ImportError: cannot import name '_C' from partially initialized module 'torchsdf' (most likely due to a circular import) (/home/ustc/PycharmProjects/DexGraspNet/TorchSDF/torchsdf/init.py)
when I tried bash install.sh,it occured

@wrc042
Copy link
Owner

wrc042 commented Mar 31, 2023

Sorry for replying so late. I tried to install torchsdf on three machines (two Ubuntu servers and one docker container on my Windows laptop) with conda, and didn't encounter such circular import, failing to repeat this error. Can you tell me more about your operations? Or you can try bash clean.sh before installation. Or you can try pip install -e .. Or you can manually modify csdf/__init__.py. Hope this can help you a little.

@ccmCCMfk
Copy link
Author

ccmCCMfk commented Apr 2, 2023

Sorry for replying so late. I tried to install torchsdf on three machines (two Ubuntu servers and one docker container on my Windows laptop) with conda, and didn't encounter such circular import, failing to repeat this error. Can you tell me more about your operations? Or you can try bash clean.sh before installation. Or you can try pip install -e .. Or you can manually modify csdf/__init__.py. Hope this can help you a little.

conda create -n graspnet python=3.8
conda activate graspnet
install pytorch and pytorch3d:
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
conda install -c fvcore -c iopath -c conda-forge fvcore iopath
pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1110/download.html

Package:
conda install transforms3d -c conda-forge
conda install plotly -c conda-forge
conda install trimesh -c conda-forge
pip install urdf_parser_py
pip install scipy
pip install networkx
conda install rtree
cd Projects/cd DexGraspNet/

sent documents to my server:
scp -P 25422 -r /home/ustc/PycharmProjects/DexGraspNet/TorchSDF [email protected]:/home/chenchangmao/Projects/DexGraspNet

do:
cd TorchSDF/
git checkout 0.1.0
bash install.sh

error:
RuntimeError:
The detected CUDA version (9.1) mismatches the version that was used to compile
PyTorch (11.3). Please make sure to use the same CUDA versions

ImportError: cannot import name '_C' from partially initialized module 'torchsdf'
That's all that I have done.

@ccmCCMfk
Copy link
Author

ccmCCMfk commented Apr 2, 2023

Sorry for replying so late. I tried to install torchsdf on three machines (two Ubuntu servers and one docker container on my Windows laptop) with conda, and didn't encounter such circular import, failing to repeat this error. Can you tell me more about your operations? Or you can try bash clean.sh before installation. Or you can try pip install -e .. Or you can manually modify csdf/__init__.py. Hope this can help you a little.

conda create -n graspnet python=3.8 conda activate graspnet install pytorch and pytorch3d: conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch conda install -c fvcore -c iopath -c conda-forge fvcore iopath pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1110/download.html

Package: conda install transforms3d -c conda-forge conda install plotly -c conda-forge conda install trimesh -c conda-forge pip install urdf_parser_py pip install scipy pip install networkx conda install rtree cd Projects/cd DexGraspNet/

sent documents to my server: scp -P 25422 -r /home/ustc/PycharmProjects/DexGraspNet/TorchSDF [email protected]:/home/chenchangmao/Projects/DexGraspNet

do: cd TorchSDF/ git checkout 0.1.0 bash install.sh

error: RuntimeError: The detected CUDA version (9.1) mismatches the version that was used to compile PyTorch (11.3). Please make sure to use the same CUDA versions

ImportError: cannot import name '_C' from partially initialized module 'torchsdf' That's all that I have done.
I also tried bash clean.sh and pip install -e.,it didn't work.

@wrc042
Copy link
Owner

wrc042 commented Apr 2, 2023

I notice that "The detected CUDA version (9.1) mismatches the version that was used to compile PyTorch (11.3). Please make sure to use the same CUDA versions".

Maybe you can check your cuda complier version by nvcc -V. For my two tested Ubuntu servers, they are "Cuda compilation tools, release 11.7, V11.7.64" and "Cuda compilation tools, release 11.3, V11.3.58". Note that "cuda compilation tools" is not "cudatoolkit" installed by conda, but installed on your native system. So I guess the error is due to the lower version of your cuda compilation tools.

Maybe you can have a try to install torchsdf (just pytorch and torchsdf) on a machine with higher cuda version to see if the same error would happen. Or you can try to install a higher version cuda on your working machine. (For exmaple, https://developer.nvidia.com/cuda-11.3.0-download-archive) By "runfile(local)" installation, you can either ask sudoer to update cuda (though I do not recommand), or install cuda into your user environment.

Hope these can help you.

@ccmCCMfk
Copy link
Author

ccmCCMfk commented Apr 4, 2023

I notice that "The detected CUDA version (9.1) mismatches the version that was used to compile PyTorch (11.3). Please make sure to use the same CUDA versions".

Maybe you can check your cuda complier version by nvcc -V. For my two tested Ubuntu servers, they are "Cuda compilation tools, release 11.7, V11.7.64" and "Cuda compilation tools, release 11.3, V11.3.58". Note that "cuda compilation tools" is not "cudatoolkit" installed by conda, but installed on your native system. So I guess the error is due to the lower version of your cuda compilation tools.

Maybe you can have a try to install torchsdf (just pytorch and torchsdf) on a machine with higher cuda version to see if the same error would happen. Or you can try to install a higher version cuda on your working machine. (For exmaple, https://developer.nvidia.com/cuda-11.3.0-download-archive) By "runfile(local)" installation, you can either ask sudoer to update cuda (though I do not recommand), or install cuda into your user environment.

Hope these can help you.

Thank you very much! I replace cuda complier 9.1 with version 11.3, it worded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants