TencentARC / InstantMesh

InstantMesh: Efficient 3D Mesh Generation from a Single Image with Sparse-view Large Reconstruction Models
Apache License 2.0
2.7k stars 262 forks source link

DLL Load Error #34

Open wmcnamara opened 2 months ago

wmcnamara commented 2 months ago

Hello! When running the model I am recieving a DLL load error.

ImportError: DLL load failed while importing nvdiffrast_plugin: The specified module could not be found.

The entire log is as follows:

PS E:\instantmesh> python run.py configs/instant-mesh-large.yaml examples/hatsune_miku.png --save_video --export_texmap
Seed set to 42
Loading diffusion model ...
Loading pipeline components...:  12%|██████▌                                             | 1/8 [00:00<00:02,  2.96it/s]The config attributes {'dropout': 0.0, 'reverse_transformer_layers_per_block': None} were passed to UNet2DConditionModel, but are not expected and will be ignored. Please verify your config.json configuration file.
Loading pipeline components...: 100%|████████████████████████████████████████████████████| 8/8 [00:08<00:00,  1.10s/it]
Loading custom white-background unet ...
Loading reconstruction model ...
Some weights of ViTModel were not initialized from the model checkpoint at facebook/dino-vitb16 and are newly initialized: ['encoder.layer.5.adaLN_modulation.1.weight', 'encoder.layer.7.adaLN_modulation.1.weight', 'encoder.layer.4.adaLN_modulation.1.weight', 'encoder.layer.1.adaLN_modulation.1.bias', 'encoder.layer.10.adaLN_modulation.1.weight', 'encoder.layer.6.adaLN_modulation.1.weight', 'encoder.layer.5.adaLN_modulation.1.bias', 'encoder.layer.0.adaLN_modulation.1.bias', 'encoder.layer.4.adaLN_modulation.1.bias', 'encoder.layer.9.adaLN_modulation.1.weight', 'encoder.layer.3.adaLN_modulation.1.weight', 'encoder.layer.2.adaLN_modulation.1.weight', 'encoder.layer.10.adaLN_modulation.1.bias', 'encoder.layer.3.adaLN_modulation.1.bias', 'encoder.layer.11.adaLN_modulation.1.bias', 'encoder.layer.2.adaLN_modulation.1.bias', 'encoder.layer.1.adaLN_modulation.1.weight', 'encoder.layer.0.adaLN_modulation.1.weight', 'encoder.layer.9.adaLN_modulation.1.bias', 'encoder.layer.6.adaLN_modulation.1.bias', 'encoder.layer.11.adaLN_modulation.1.weight', 'encoder.layer.8.adaLN_modulation.1.bias', 'encoder.layer.8.adaLN_modulation.1.weight', 'encoder.layer.7.adaLN_modulation.1.bias']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Traceback (most recent call last):
  File "E:\instantmesh\run.py", line 132, in <module>
    model.init_flexicubes_geometry(device, fovy=30.0)
  File "E:\instantmesh\src\models\lrm_mesh.py", line 79, in init_flexicubes_geometry
    renderer = NeuralRender(device, camera_model=camera)
  File "E:\instantmesh\src\models\geometry\render\neural_render.py", line 73, in __init__
    self.ctx = dr.RasterizeCudaContext(device=device)
  File "C:\Users\Weston\AppData\Local\Programs\Python\Python310\lib\site-packages\nvdiffrast\torch\ops.py", line 177, in __init__
    self.cpp_wrapper = _get_plugin().RasterizeCRStateWrapper(cuda_device_idx)
  File "C:\Users\Weston\AppData\Local\Programs\Python\Python310\lib\site-packages\nvdiffrast\torch\ops.py", line 118, in _get_plugin
    torch.utils.cpp_extension.load(name=plugin_name, sources=source_paths, extra_cflags=opts, extra_cuda_cflags=opts+['-lineinfo'], extra_ldflags=ldflags, with_cuda=True, verbose=False)
  File "C:\Users\Weston\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\cpp_extension.py", line 1308, in load
    return _jit_compile(
  File "C:\Users\Weston\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\cpp_extension.py", line 1736, in _jit_compile
    return _import_module_from_library(name, build_directory, is_python_module)
  File "C:\Users\Weston\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\cpp_extension.py", line 2136, in _import_module_from_library
    module = importlib.util.module_from_spec(spec)
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1176, in create_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ImportError: DLL load failed while importing nvdiffrast_plugin: The specified module could not be found.

Any ideas how this could happen? Did I miss a porgram that must be installed?

wikeeyang commented 2 months ago

The same error as above run "python app.py" , my environment: Windows 11 x64 Visual Studio 2019, all PATH / LIB / include parameter seted. and this enviroment to run CUDA compile is ok for example OOTDiffusion project and other's. ‘cl’ command run ok:

D:\AITest\InstantMesh>cl 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30148 版 版权所有(C) Microsoft Corporation。保留所有权利。

用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]

wikeeyang commented 2 months ago

supplement: just now, according to https://nvlabs.github.io/nvdiffrast/#windows docement, i try to run "python triangle.py --cuda" in the same terminal window, it's run ok and produced the image as below: 2024-04-22_171943 tri is this means the package "nvdiffrast" install is no problem?

wikeeyang commented 2 months ago

haha... after I finished run the sample test of nvdiffrast's python script "triangle.py", I find the nvdiffrast_plugin library in the torch_extensions cache directory “C:\Users\Administrator\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu121\nvdiffrast_plugin” as below:

2024-04-22_193304

then I run the app.py again, working fine, I think may be it was recompile during my testing above. the file's timestamp also proofed it did compile twice, then may be the first time when I install the requirement.txt, the nvdiffrast's wheel build have some error but wasn't any warning...below is the log message:

Building wheels for collected packages: diffusers, nvdiffrast Building wheel for diffusers (pyproject.toml) ... done Created wheel for diffusers: filename=diffusers-0.20.2-py3-none-any.whl size=1342627 sha256=4317a52ec7c0e3efa4f689f2bc93489ce075494c4fe36c0debc339dcd8aed419 Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\86\7f\62\8d24bc8f23ae7fa8fa72c981ce769844f6aa2098b0587a63ba Building wheel for nvdiffrast (pyproject.toml) ... done Created wheel for nvdiffrast: filename=nvdiffrast-0.3.1-py3-none-any.whl size=141468 sha256=6438b8f63727e74d7eef28a20fc513d7db3a626a6f85e2977732d1e62d11694d Stored in directory: C:\Users\Administrator\AppData\Local\Temp\pip-ephem-wheel-cache-mfe8hywg\wheels\3e\83\20\219395b9ff5d75f2171869aeaaaa093303dcfd2c92dd5597c0 Successfully built diffusers nvdiffrast

sumanttyagi commented 2 months ago

@wikeeyang i am also facing the same issue as below do i need to set the env variable also >? line 2136, in _import_module_from_library module = importlib.util.module_from_spec(spec) File "", line 571, in module_from_spec File "", line 1176, in create_module File "", line 241, in _call_with_frames_removed ImportError: DLL load failed while importing nvdiffrast_plugin: The specified module could not be found.

wikeeyang commented 2 months ago

@wikeeyang i am also facing the same issue as below do i need to set the env variable also >? line 2136, in _import_module_from_library module = importlib.util.module_from_spec(spec) File "", line 571, in module_from_spec File "", line 1176, in create_module File "", line 241, in _call_with_frames_removed ImportError: DLL load failed while importing nvdiffrast_plugin: The specified module could not be found. @sumanttyagi due to this project need nvidia nvdiffrast package, this package need ninja to compile pytorch + cua DLL library base local enviroment, then, when you install nvdiffrast from source or from requirement.txt, you need C++ compile enviroment, gcc/g++/cmake for linux, and Microsoft Visual Studio build tools enviroment for windows, and in windows, you need plus some env parameter like LIB/INCLUDE and PATH for “cl.exe”, then ninja can invoke command line compile for nvdiffrast package local. back to the error message, should be the nvdiffrast_plugin DLL can't compiled successe, you need check and prepare for your enviroment first.

sumanttyagi commented 2 months ago

@wikeeyang can't we create env through anaconda environment following the steps provided on repo? also can you elaborate this steps need plus some env parameter like LIB/INCLUDE and PATH for “cl.exe”, then ninja can invoke command line compile for nvdiffrast package local. . Please provide the sample of the steps in detail which need to setup the env,

wikeeyang commented 2 months ago

@wikeeyang can't we create env through anaconda environment following the steps provided on repo? also can you elaborate this steps need plus some env parameter like LIB/INCLUDE and PATH for “cl.exe”, then ninja can invoke command line compile for nvdiffrast package local. . Please provide the sample of the steps in detail which need to setup the env,

@sumanttyagi I don't know your enviroment, and don't know config with anaconda, for this, you can prefer the issue#3

in my Windows 11 x64 + Visual Studio 2019 + Windows Kits 10 enviroment, the PATH/LIB/INCLUDE as below:

PATH: append your "cl.exe" file path to %PATH%,like C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64; %PATH%

LIB: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86;

INCLUDE: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared;

you need modify it according to your version...

when you compete above setting, pls goto the directory like "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build" to find "vcvarsall.bat" or "vcvars64.bat", and click right buttom to open CMD windows, to run like this "vcvarsall.bat x86_amd64 10.0.19041.0 -vcvars_ver=14.29" to config the Microsoft C++ command line compile enviroment. for this, you can refer this page for more detail information.

https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160

sumanttyagi commented 2 months ago

but we use the command line to # Install the correct version of CUDA conda install cuda -c nvidia/label/cuda-12.1.0

it will be inside the conda lib package right not here INCLUDE: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include

have you installed the cuda separately ? without using command ?

sumanttyagi commented 2 months ago

@wikeeyang is it important to install the cuda toolkit 12.1 separately ? or this command is enough conda install cuda -c nvidia/label/cuda-12.1.0

iiiCpu commented 1 month ago

Fix CUDA_PATH https://github.com/TencentARC/InstantMesh/issues/51#issuecomment-2128868173