facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.81k stars 1.32k forks source link

ImportError: DLL load failed while importing _C: The specified program could not be found. #1792

Closed 511lyf closed 6 months ago

511lyf commented 6 months ago

Hello, ImportError appeared when I installed pytorch3d using PyTorCH3D-0.7.6 +pt2.1.0cu121-cp39-cp39-win_amd64.whl: DLL load failed while importing _C: The specified program cannot be found. There is a _c.cp39-win_amd64. pyd file in the pytorch3d directory. Does this contain the contents of the _C module? Is this problem caused by my incorrect installation of pytorch3d? I am using windows11 operating system, but I can't install it correctly using the official installation method, but I can only import it correctly using whl. What should I do to solve the problem that I can't find the specified program? I am looking forward to your reply, thank you very much!

Traceback (most recent call last): File "E:\Workplace\DECA\main.py", line 15, in model = DECA(cfg).to(cfg.device) File "E:\Workplace\DECA\decalib\deca.py", line 36, in init self.setup_renderer(self.cfg.model) # 加载渲染器 File "E:\Workplace\DECA\decalib\deca.py", line 39, in setup_renderer set_rasterizer(self.cfg.rasterizer_type) File "E:\Workplace\DECA\decalib\utils\renderer.py", line 12, in set_rasterizer from pytorch3d.io import load_obj File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\io_init.py", line 8, in from .obj_io import load_obj, load_objs_as_meshes, save_obj File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\io\obj_io.py", line 22, in from pytorch3d.renderer import TexturesAtlas, TexturesUV File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\renderer_init.py", line 29, in from .implicit import ( File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\renderer\implicitinit.py", line 9, in from .raysampling import ( File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\renderer\implicit\raysampling.py", line 12, in from pytorch3d.ops import padded_to_packed File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\opsinit.py", line 28, in from .sample_farthest_points import sample_farthest_points File "D:\Setting\miniconda3\envs\pytorch\lib\site-packages\pytorch3d\ops\sample_farthest_points.py", line 14, in from pytorch3d import _C ImportError: DLL load failed while importing _C: 找不到指定的程序。

bottler commented 6 months ago

Probably there is something different between the environment where you are running and the environment where the wheel was built. The versions of cuda, pytorch and python need to all match and pytorch's cuda support must be working. Could it be that the cuda or pytorch versions are different? Can you paste the output of conda info, conda list and pip list here and explain how the wheel was built?

511lyf commented 6 months ago

您运行的环境和构建轮子的环境之间可能存在一些不同之处。cuda、pytorch 和 python 的版本需要全部匹配,并且 pytorch 的 cuda 支持必须正常工作。难道 cuda 或 pytorch 版本不同吗?你能在这里粘贴 的输出并解释轮子是如何构建的吗?conda info``conda list``pip list

# packages in environment at D:\Setting\miniconda3\envs\pytorch:
#
# Name                    Version                   Build  Channel
annotated-types           0.6.0                    pypi_0    pypi
aom                       3.6.0                hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
asttokens                 2.0.5              pyhd3eb1b0_0    defaults
attrs                     23.2.0                   pypi_0    pypi
backcall                  0.2.0              pyhd3eb1b0_0    defaults
black                     24.3.0                   pypi_0    pypi
blas                      1.0                         mkl    defaults
blis                      0.7.11                   pypi_0    pypi
blosc                     1.21.3               h6c2663c_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
bottleneck                1.3.7            py39h9128911_0    defaults
brotli                    1.0.9                h2bbff1b_7    defaults
brotli-bin                1.0.9                h2bbff1b_7    defaults
brotli-python             1.0.9            py39hd77b12b_7    defaults
bzip2                     1.0.8                h2bbff1b_5    defaults
ca-certificates           2023.08.22           haa95532_0    anaconda
catalogue                 2.0.10           py39haa95532_0    defaults
certifi                   2023.11.17       py39haa95532_0    anaconda
cffi                      1.16.0           py39h2bbff1b_0    defaults
cfitsio                   3.470                h2bbff1b_7    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
charls                    2.2.0                h6c2663c_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
chumpy                    0.70                     pypi_0    pypi
click                     8.1.7                    pypi_0    pypi
cloudpathlib              0.16.0                   pypi_0    pypi
cmake                     3.26.4               h693b641_0    defaults
colorama                  0.4.6            py39haa95532_0    defaults
comm                      0.2.1            py39haa95532_0    defaults
confection                0.1.3                    pypi_0    pypi
cuda-cccl                 12.2.128                      0    nvidia
cuda-cudart               12.1.105                      0    nvidia
cuda-cudart-dev           12.1.105                      0    nvidia
cuda-cupti                12.1.105                      0    nvidia
cuda-libraries            12.1.0                        0    nvidia
cuda-libraries-dev        12.1.0                        0    nvidia
cuda-nvrtc                12.1.105                      0    nvidia
cuda-nvrtc-dev            12.1.105                      0    nvidia
cuda-nvtx                 12.1.105                      0    nvidia
cuda-opencl               12.4.127                      0    nvidia
cuda-opencl-dev           12.4.127                      0    nvidia
cuda-profiler-api         12.2.128                      0    nvidia
cuda-runtime              12.1.0                        0    nvidia
cycler                    0.11.0             pyhd3eb1b0_0    defaults
cymem                     2.0.8                    pypi_0    pypi
cython                    3.0.6            py39h2bbff1b_0    defaults
dataclasses               0.8                pyh6d0b6a4_7    anaconda
dav1d                     1.2.1                h2bbff1b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
debugpy                   1.6.7            py39hd77b12b_0    defaults
decorator                 5.1.1              pyhd3eb1b0_0    defaults
dlib                      19.24.0          py39hf8509d4_0    conda-forge
dominate                  2.8.0                    pypi_0    pypi
double-conversion         3.1.5                ha925a31_1    defaults
eigen                     3.4.0                h59b6b97_0    defaults
en-core-web-sm            3.7.0                    pypi_0    pypi
entrypoints               0.4              py39haa95532_0    defaults
et-xmlfile                1.1.0                    pypi_0    pypi
exceptiongroup            1.2.0            py39haa95532_0    defaults
executing                 0.8.3              pyhd3eb1b0_0    defaults
expat                     2.5.0                hd77b12b_0    defaults
face-alignment            1.4.1                    pypi_0    pypi
facenet-pytorch           2.5.3                    pypi_0    pypi
ffmpeg                    4.2.2                he774522_0    defaults
filelock                  3.13.1           py39haa95532_0    defaults
flake8                    7.0.0                    pypi_0    pypi
flake8-bugbear            24.2.6                   pypi_0    pypi
flake8-comprehensions     3.14.0                   pypi_0    pypi
fonttools                 4.25.0             pyhd3eb1b0_0    defaults
freetype                  2.12.1               ha860e81_0    defaults
freetype-py               2.2.0              pyhd3eb1b0_0    anaconda
fsspec                    2023.10.0        py39haa95532_0    defaults
future                    0.18.3           py39haa95532_0    anaconda
fvcore                    0.1.5.post20221221    pyhd8ed1ab_0    conda-forge
giflib                    5.2.1                h8cc25b3_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
gl2ps                     1.4.2                hce2df77_1    defaults
glew                      2.1.0                hd77b12b_3    defaults
gmpy2                     2.1.2            py39h7f96b67_0    defaults
hdf4                      4.2.13               h712560f_2    defaults
hdf5                      1.12.1               h51c971a_3    defaults
huggingface_hub           0.20.3           py39haa95532_0    defaults
icc_rt                    2022.1.0             h6049295_2    defaults
icu                       73.1                 h6c2663c_0    defaults
idna                      3.4              py39haa95532_0    defaults
imagecodecs               2023.1.23        py39h6c6a46e_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
imageio                   2.31.3                   pypi_0    pypi
imageio-ffmpeg            0.4.9              pyhd8ed1ab_0    conda-forge
importlib-metadata        7.0.1            py39haa95532_0    defaults
importlib_metadata        7.0.1                hd3eb1b0_0    defaults
intel-openmp              2023.1.0         h59b6b97_46320    anaconda
iopath                    0.1.9                      py39    iopath
ipdb                      0.13.13                  pypi_0    pypi
ipykernel                 6.28.0           py39haa95532_0    defaults
ipyparallel               8.6.1            py39haa95532_0    defaults
ipython                   8.15.0           py39haa95532_0    defaults
jedi                      0.18.1           py39haa95532_1    defaults
jinja2                    3.1.3            py39haa95532_0    defaults
joblib                    1.2.0            py39haa95532_0    defaults
jpeg                      9e                   h2bbff1b_1    defaults
jsoncpp                   1.9.4                h59b6b97_3    defaults
jsonpatch                 1.33                     pypi_0    pypi
jsonpointer               2.4                      pypi_0    pypi
jupyter_client            8.6.0            py39haa95532_0    defaults
jupyter_core              5.5.0            py39haa95532_0    defaults
kiwisolver                1.4.4            py39hd77b12b_0    defaults
kornia                    0.7.0                    pypi_0    pypi
krb5                      1.20.1               h5b6d351_0    defaults
lazy_loader               0.3              py39haa95532_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lcms2                     2.12                 h83e58a3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lerc                      3.0                  hd77b12b_0    defaults
libaec                    1.0.4                h33f27b4_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libavif                   0.11.1               h2bbff1b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libbrotlicommon           1.0.9                h2bbff1b_7    defaults
libbrotlidec              1.0.9                h2bbff1b_7    defaults
libbrotlienc              1.0.9                h2bbff1b_7    defaults
libclang                  14.0.6          default_hb5a9fac_1    defaults
libclang13                14.0.6          default_h8e68704_1    defaults
libcst                    1.2.0                    pypi_0    pypi
libcublas                 12.1.0.26                     0    nvidia
libcublas-dev             12.1.0.26                     0    nvidia
libcufft                  11.0.2.4                      0    nvidia
libcufft-dev              11.0.2.4                      0    nvidia
libcurand                 10.3.3.129                    0    nvidia
libcurand-dev             10.3.3.129                    0    nvidia
libcurl                   8.5.0                h86230a5_0    defaults
libcusolver               11.4.4.55                     0    nvidia
libcusolver-dev           11.4.4.55                     0    nvidia
libcusparse               12.0.2.55                     0    nvidia
libcusparse-dev           12.0.2.55                     0    nvidia
libdeflate                1.17                 h2bbff1b_1    defaults
libiconv                  1.16                 h2bbff1b_2    defaults
libnetcdf                 4.8.1                h6685c40_4    defaults
libnpp                    12.0.2.50                     0    nvidia
libnpp-dev                12.0.2.50                     0    nvidia
libnvjitlink              12.1.105                      0    nvidia
libnvjitlink-dev          12.1.105                      0    nvidia
libnvjpeg                 12.1.1.14                     0    nvidia
libnvjpeg-dev             12.1.1.14                     0    nvidia
libogg                    1.3.5                h2bbff1b_1    defaults
libpng                    1.6.39               h8cc25b3_0    defaults
libpq                     12.17                h906ac69_0    defaults
libsodium                 1.0.18               h62dcd97_0    defaults
libssh2                   1.10.0               he2ea4bf_2    defaults
libtheora                 1.1.1                h8cc25b3_3    defaults
libtiff                   4.5.1                hd77b12b_0    defaults
libuv                     1.44.2               h2bbff1b_0    defaults
libwebp-base              1.3.2                h2bbff1b_0    defaults
libxml2                   2.9.14               h0ad7f3c_0    defaults
libzip                    1.8.0                h289538f_1    defaults
libzopfli                 1.0.3                ha925a31_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
llvmlite                  0.42.0                   pypi_0    pypi
loguru                    0.5.3            py39haa95532_4    defaults
lz4-c                     1.9.4                h2bbff1b_0    defaults
markupsafe                2.1.3            py39h2bbff1b_0    defaults
matplotlib                3.5.3            py39hcbf5309_2    conda-forge
matplotlib-base           3.5.3            py39hd77b12b_0    defaults
matplotlib-inline         0.1.6            py39haa95532_0    defaults
mccabe                    0.7.0                    pypi_0    pypi
metakernel                0.27.5             pyhd3eb1b0_0    defaults
mkl                       2023.1.0         h6b88ed4_46358    defaults
mkl-service               2.4.0            py39h2bbff1b_1    defaults
mkl_fft                   1.3.8            py39h2bbff1b_0    defaults
mkl_random                1.2.4            py39h59b6b97_0    defaults
moreorless                0.4.0                    pypi_0    pypi
moviepy                   1.0.3              pyhd8ed1ab_1    conda-forge
mpc                       1.1.0                h7edee0f_1    defaults
mpfr                      4.0.2                h62dcd97_1    defaults
mpir                      3.0.0                hec2e145_1    defaults
mpmath                    1.3.0            py39haa95532_0    defaults
munkres                   1.1.4                      py_0    defaults
murmurhash                1.0.10                   pypi_0    pypi
mxnet                     0.11.0                   pypi_0    pypi
mypy-extensions           1.0.0                    pypi_0    pypi
nest-asyncio              1.6.0            py39haa95532_0    defaults
networkx                  3.1              py39haa95532_0    defaults
ninja                     1.10.2               haa95532_5    defaults
ninja-base                1.10.2               h6d14046_5    defaults
numba                     0.59.1                   pypi_0    pypi
numexpr                   2.8.7            py39h2cd9be0_0    defaults
numpy                     1.23.0                   pypi_0    pypi
numpy-base                1.26.4           py39h65a83cf_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-stl                 3.1.1                    pypi_0    pypi
oct2py                    5.6.0              pyha21a80b_0    conda-forge
octave_kernel             0.35.1             pyhd8ed1ab_0    conda-forge
opencv-contrib-python     4.8.1.78                 pypi_0    pypi
opencv-python             4.8.0.76                 pypi_0    pypi
openjpeg                  2.4.0                h4fc8c34_0    defaults
openpyxl                  3.1.2                    pypi_0    pypi
openssl                   3.0.12               h2bbff1b_0    anaconda
packaging                 23.2             py39haa95532_0    defaults
pandas                    1.5.3            py39hf11a4ad_0    defaults
parso                     0.8.3              pyhd3eb1b0_0    defaults
pathspec                  0.12.1                   pypi_0    pypi
pexpect                   4.8.0              pyhd3eb1b0_3    defaults
pickleshare               0.7.5           pyhd3eb1b0_1003    defaults
pillow                    10.2.0           py39h2bbff1b_0    defaults
pip                       23.3.2                   pypi_0    pypi
platformdirs              4.2.0                    pypi_0    pypi
plotly                    5.20.0                   pypi_0    pypi
ply                       3.11             py39haa95532_0    defaults
portalocker               2.3.0            py39haa95532_1    defaults
preshed                   3.0.9                    pypi_0    pypi
proglog                   0.1.9                      py_0    conda-forge
proj                      6.2.1                h3758d61_0    defaults
prompt-toolkit            3.0.43           py39haa95532_0    defaults
psutil                    5.9.0            py39h2bbff1b_0    defaults
ptyprocess                0.7.0              pyhd3eb1b0_2    defaults
pure_eval                 0.2.2              pyhd3eb1b0_0    defaults
pycodestyle               2.11.1                   pypi_0    pypi
pycparser                 2.21               pyhd3eb1b0_0    defaults
pydantic                  2.6.4                    pypi_0    pypi
pydantic-core             2.16.3                   pypi_0    pypi
pyflakes                  3.2.0                    pypi_0    pypi
pyglet                    1.5.27           py39hcbf5309_4    conda-forge
pygments                  2.15.1           py39haa95532_1    defaults
pyopengl                  3.1.1a1          py39haa95532_0    defaults
pyparsing                 3.0.9            py39haa95532_0    defaults
pyqt                      5.15.10          py39hd77b12b_0    defaults
pyqt5-sip                 12.13.0          py39h2bbff1b_0    defaults
pyrender                  0.1.45             pyh8a188c0_3    conda-forge
pysocks                   1.7.1            py39haa95532_0    defaults
python                    3.9.18               h1aa4202_0    defaults
python-dateutil           2.8.2              pyhd3eb1b0_0    defaults
python-graphviz           0.20.1                   pypi_0    pypi
python-utils              3.8.2                    pypi_0    pypi
python_abi                3.9                      2_cp39    conda-forge
pytorch-cuda              12.1                 hde6ce7c_5    pytorch
pytorch3d                 0.7.6+pt2.1.0cu121          pypi_0    pypi
pytz                      2023.3.post1     py39haa95532_0    defaults
pywavelets                1.4.1                    pypi_0    pypi
pywin32                   305              py39h2bbff1b_0    defaults
pyyaml                    6.0.1            py39h2bbff1b_0    defaults
pyzmq                     25.1.2           py39hd77b12b_0    defaults
qt-main                   5.15.2              h19c9488_10    defaults
regex                     2023.10.3        py39h2bbff1b_0    defaults
requests                  2.31.0           py39haa95532_1    defaults
safetensors               0.4.2            py39h0010962_0    defaults
scikit-image              0.22.0                   pypi_0    pypi
scikit-learn              1.3.0            py39h4ed8f06_0    anaconda
scipy                     1.11.2                   pypi_0    pypi
setuptools                68.2.1                   pypi_0    pypi
sip                       6.7.12           py39hd77b12b_0    defaults
six                       1.16.0             pyhd3eb1b0_1    defaults
smart-open                6.4.0                    pypi_0    pypi
smplx                     0.1.28                   pypi_0    pypi
snappy                    1.1.10               h6c2663c_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
some-package              0.1                      pypi_0    pypi
spacy-loggers             1.0.5                    pypi_0    pypi
sqlite                    3.41.2               h2bbff1b_0    defaults
srsly                     2.4.8            py39hd77b12b_1    defaults
stack_data                0.2.0              pyhd3eb1b0_0    defaults
stdlibs                   2024.1.28                pypi_0    pypi
sympy                     1.12             py39haa95532_0    defaults
tabulate                  0.9.0            py39haa95532_0    defaults
tbb                       2021.8.0             h59b6b97_0    defaults
tenacity                  8.2.3                    pypi_0    pypi
tensorflow-addons         0.21.0                   pypi_0    pypi
termcolor                 2.1.0            py39haa95532_0    defaults
tf-slim                   1.1.0                    pypi_0    pypi
thinc                     8.2.1                    pypi_0    pypi
threadpoolctl             2.2.0              pyh0d69192_0    defaults
tifffile                  2023.8.30                pypi_0    pypi
tokenizers                0.15.1           py39h49fca51_0    defaults
toml                      0.10.2                   pypi_0    pypi
tomli                     2.0.1            py39haa95532_0    defaults
torch                     2.2.2+cu121              pypi_0    pypi
torchaudio                2.2.2+cu121              pypi_0    pypi
torchvision               0.17.2+cu121             pypi_0    pypi
tornado                   6.3.3            py39h2bbff1b_0    defaults
tqdm                      4.65.0           py39hd4e2768_0    defaults
trailrunner               1.4.0                    pypi_0    pypi
traitlets                 5.7.1            py39haa95532_0    defaults
transformers              4.37.2           py39haa95532_0    defaults
trimesh                   3.17.1                   pypi_0    pypi
typeguard                 2.13.3                   pypi_0    pypi
typer                     0.9.0                    pypi_0    pypi
typing-extensions         4.10.0                   pypi_0    pypi
typing-inspect            0.9.0                    pypi_0    pypi
typing_extensions         4.9.0            py39haa95532_1    defaults
tzdata                    2024a                h04d1e81_0    defaults
urllib3                   2.1.0            py39haa95532_1    defaults
usort                     1.0.8.post1              pypi_0    pypi
utfcpp                    3.2.1                haa95532_0    defaults
vc                        14.2                 h21ff451_1    defaults
visdom                    0.2.4                    pypi_0    pypi
visvis                    1.13.0             pyhd3eb1b0_0    defaults
vs2015_runtime            14.27.29016          h5e58377_2    defaults
vtk                       9.0.3           py39h84a6d72_201    defaults
wasabi                    1.1.2                    pypi_0    pypi
wcwidth                   0.2.5              pyhd3eb1b0_0    defaults
weasel                    0.3.4                    pypi_0    pypi
wheel                     0.41.2           py39haa95532_0    defaults
win32_setctime            1.1.0              pyhd3eb1b0_0    defaults
win_inet_pton             1.1.0            py39haa95532_0    defaults
xlrd                      2.0.1                    pypi_0    pypi
xz                        5.4.6                h8cc25b3_0    defaults
yacs                      0.1.8                    pypi_0    pypi
yaml                      0.2.5                he774522_0    defaults
zeromq                    4.3.5                hd77b12b_0    defaults
zfp                       1.0.0                hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zipp                      3.17.0           py39haa95532_0    defaults
zlib                      1.2.13               h8cc25b3_0    defaults
zstd                      1.5.5                hd43e919_0    defaults

This is all the packages installed in my virtual environment. Here are my cuda and pytorch versions: QQ图片20240509202703 QQ图片20240509202708 001

Build on WHL, I from https://miropsota.github.io/torch_packages_builder/pytorch3d/ Find the whl file that matches my version from this website, download it in the virtual environment D:\Setting\miniconda3\envs\pytorch\Lib\site-packages, Then activate the virtual environment in Anaconda Prompt (miniconda3), Use pip install D: / Setting/miniconda3 / envs pytorch/Lib/site - packages/pytorch3d - 0.7.6 + pt2.1.0 cu121 cp39 - cp39 - win_amd64. WHL pytorch3d command to install, You can import pytorch3d correctly, but you cannot use from pytorch3d import _C, the error message is that the module cannot be found

I really do not know where the problem is, looking forward to your reply, Thank you.

bottler commented 6 months ago

You seem to have PyTorch 2.2.2 in the environment but the wheel was built with PyTorch 2.1.0. That will never work.

511lyf commented 6 months ago

Ok, this is something I haven't noticed. I'll try to reinstall it. Thank you very much!

511lyf commented 6 months ago

You seem to have PyTorch 2.2.2 in the environment but the wheel was built with PyTorch 2.1.0. That will never work.

Thank you very much. The problem that has been bothering me for days has finally been solved. Thank you for your help. I will continue to explore the application of pytorch3d in real projects and look forward to talking to you again!