pytorch3d
pytorch3d copied to clipboard
Unit tests failing ImportError: cannot import name '_C' from 'pytorch3d'
Following the install instructions when I get to python setup.py install I end up with this. I had downloaded ninja and added it to my path, without ninja a don't get as far it quit earlier
C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/include\crtdefs.h(10): fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory marching_cubes.cu
I ended up reinstalling everything and making to sure to include the necessary components in the VS build tools installer. It seems to be working on my Windows 10 machine. Also removed ninja from path
windows 10 SDK Cuda 11.8 Vsstudio build tools for VS19 Universal CRT SDK x64 build tools for c++
It appear the unit tests are failing now:
python3 -m unittest discover -v -s tests -t .
ERROR: tests.test_vis (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.test_vis
Traceback (most recent call last):
File "C:\Users\User\anaconda3\envs\pytorch3d\lib\unittest\loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "C:\Users\User\anaconda3\envs\pytorch3d\lib\unittest\loader.py", line 377, in _get_module_from_name
__import__(name)
File "C:\Users\User\pythorch3d\tests\test_vis.py", line 10, in <module>
from pytorch3d.renderer import HeterogeneousRayBundle, PerspectiveCameras, RayBundle
File "C:\Users\User\pythorch3d\pytorch3d\renderer\__init__.py", line 7, in <module>
from .blending import (
File "C:\Users\User\pythorch3d\pytorch3d\renderer\blending.py", line 10, in <module>
from pytorch3d import _C
ImportError: cannot import name '_C' from 'pytorch3d' (C:\Users\User\pythorch3d\pytorch3d\__init__.py)
moved to python 3.10 and upgraded pytorch less errors in unit tests but still same cannot import issue
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
I think the problem here may be a gotcha with paths. Are you installing with -e/--editable on pip install? I think you might not be. That means there are two separate directories containing the pytorch3d code: the one in your checkout (i.e. C:\Users\User\pythorch3d\pytorch3d\), and the one which is installed (probably "C:\Users\User\anaconda3\envs\pytorch3d\lib\python3.10\site-packages\pytorch3d") and only the second one is a proper install with the _C DLL file. Because you are running the tests from C:\Users\User\pythorch3d, imports of pytorch3d are looking at the local one.
To test this theory, can you try moving to another directory and starting python and running from pytorch3d.renderer import HeterogeneousRayBundle, PerspectiveCameras, RayBundle, which I expect to work. In this case pytorch3d is installed correctly but is unusable from the source directory. To run the tests, you could temporarily rename the folder C:\Users\User\pythorch3d\pytorch3d to something else. To avoid this problem for future installs, I recommend using pip install -e.
If this theory is wrong and the installation of pytorch3d definitely succeeded, then you probably have a file called _C<something>.dll in C:\Users\User\pythorch3d\pytorch3d which python does not like for some reason. If so, I suggest opening that file in dependency walker or a debugger and sharing any interesting errors from that here.