DLL load failed
marwanmusa opened this issue · 13 comments
I got error with cpp_extension.py
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 5
2 sys.path.append(".")
3 sys.path.append('[./DragGAN](https://file+.vscode-resource.vscode-cdn.net/f%3A/MyFile/DragGAN/DragGAN)')
----> 5 from gradio_app import main
File [f:\MyFile\DragGAN\gradio_app.py:9](file:///F:/MyFile/DragGAN/gradio_app.py:9)
6 from PIL import Image
7 import uuid
----> 9 from drag_gan import drag_gan, stylegan2
11 device = 'cuda'
14 SIZE_TO_CLICK_SIZE = {
15 1024: 5,
16 256: 2
17 }
File [f:\MyFile\DragGAN\drag_gan.py:12](file:///F:/MyFile/DragGAN/drag_gan.py:12)
9 from torchvision import utils
10 from tqdm import tqdm
---> 12 from stylegan2.model import Generator
15 class DownloadProgressBar(tqdm):
16 def update_to(self, b=1, bsize=1, tsize=None):
File [f:\MyFile\DragGAN\stylegan2\model.py:8](file:///F:/MyFile/DragGAN/stylegan2/model.py:8)
5 from torch import nn
6 from torch.nn import functional as F
----> 8 from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
11 class PixelNorm(nn.Module):
12 def __init__(self):
File [f:\MyFile\DragGAN\stylegan2\op\__init__.py:1](file:///F:/MyFile/DragGAN/stylegan2/op/__init__.py:1)
----> 1 from .fused_act import FusedLeakyReLU, fused_leaky_relu
2 from .upfirdn2d import upfirdn2d
File [f:\MyFile\DragGAN\stylegan2\op\fused_act.py:11](file:///F:/MyFile/DragGAN/stylegan2/op/fused_act.py:11)
7 from torch.utils.cpp_extension import load
10 module_path = os.path.dirname(__file__)
---> 11 fused = load(
12 "fused",
13 sources=[
14 os.path.join(module_path, "fused_bias_act.cpp"),
15 os.path.join(module_path, "fused_bias_act_kernel.cu"),
16 ],
17 )
20 class FusedLeakyReLUFunctionBackward(Function):
21 @staticmethod
22 def forward(ctx, grad_output, out, bias, negative_slope, scale):
File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1284](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1284), in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
1192 def load(name,
1193 sources: Union[str, List[str]],
1194 extra_cflags=None,
(...)
1202 is_standalone=False,
1203 keep_intermediates=True):
1204 r'''
1205 Loads a PyTorch C++ extension just-in-time (JIT).
1206
(...)
1282 ... verbose=True)
1283 '''
-> 1284 return _jit_compile(
1285 name,
1286 [sources] if isinstance(sources, str) else sources,
1287 extra_cflags,
1288 extra_cuda_cflags,
1289 extra_ldflags,
1290 extra_include_paths,
1291 build_directory or _get_build_directory(name, verbose),
1292 verbose,
1293 with_cuda,
1294 is_python_module,
1295 is_standalone,
1296 keep_intermediates=keep_intermediates)
File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1535](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1535), in _jit_compile(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
1532 if is_standalone:
1533 return _get_exec_path(name, build_directory)
-> 1535 return _import_module_from_library(name, build_directory, is_python_module)
File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1929](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1929), in _import_module_from_library(module_name, path, is_python_module)
1927 spec = importlib.util.spec_from_file_location(module_name, filepath)
1928 assert spec is not None
-> 1929 module = importlib.util.module_from_spec(spec)
1930 assert isinstance(spec.loader, importlib.abc.Loader)
1931 spec.loader.exec_module(module)
ImportError: DLL load failed while importing fused: The specified module could not be found.
previously, I got this error
CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
then, I try to change ['ninja', '-v']
to ['ninja', '--version']
(got this solution while exploring on stackoverflow
) .
and then, this Error : *DLL load failed*
show up.
Can anybody help with this?
I use virtual environment, and these all lib that I installed
-i https://pypi.org/simple
aiofiles==23.1.0 ; python_version >= '3.7' and python_version < '4.0'
aiohttp==3.8.4 ; python_version >= '3.6'
aiosignal==1.3.1 ; python_version >= '3.7'
altair==5.0.0 ; python_version >= '3.7'
anyio==3.6.2 ; python_full_version >= '3.6.2'
asttokens==2.2.1
async-timeout==4.0.2 ; python_version >= '3.6'
attrs==23.1.0 ; python_version >= '3.7'
backcall==0.2.0
certifi==2023.5.7 ; python_version >= '3.6'
charset-normalizer==3.1.0 ; python_full_version >= '3.7.0'
click==8.1.3 ; python_version >= '3.7'
colorama==0.4.6 ; platform_system == 'Windows'
comm==0.1.3 ; python_version >= '3.6'
contourpy==1.0.7 ; python_version >= '3.8'
cycler==0.11.0 ; python_version >= '3.6'
debugpy==1.6.7 ; python_version >= '3.7'
decorator==5.1.1 ; python_version >= '3.5'
executing==1.2.0
fastapi==0.95.2 ; python_version >= '3.7'
ffmpy==0.3.0
filelock==3.12.0 ; python_version >= '3.7'
fire==0.5.0
fonttools==4.39.4 ; python_version >= '3.8'
frozenlist==1.3.3 ; python_version >= '3.7'
fsspec==2023.5.0 ; python_version >= '3.8'
gradio==3.32.0
gradio-client==0.2.5 ; python_version >= '3.7'
h11==0.14.0 ; python_version >= '3.7'
httpcore==0.17.1 ; python_version >= '3.7'
httpx==0.24.1 ; python_version >= '3.7'
huggingface-hub==0.14.1 ; python_full_version >= '3.7.0'
idna==3.4 ; python_version >= '3.5'
imageio==2.28.1
imageio-ffmpeg==0.4.8
ipykernel==6.23.1
ipython==8.13.2 ; python_version >= '3.9'
ipywidgets==8.0.6
jedi==0.18.2 ; python_version >= '3.6'
jinja2==3.1.2 ; python_version >= '3.7'
jsonschema==4.17.3 ; python_version >= '3.7'
jupyter-client==8.2.0 ; python_version >= '3.8'
jupyter-core==5.3.0 ; python_version >= '3.8'
jupyterlab-widgets==3.0.7 ; python_version >= '3.7'
kiwisolver==1.4.4 ; python_version >= '3.7'
linkify-it-py==2.0.2
markdown-it-py[linkify]==2.2.0 ; python_version >= '3.7'
markupsafe==2.1.2 ; python_version >= '3.7'
matplotlib==3.7.1 ; python_version >= '3.8'
matplotlib-inline==0.1.6 ; python_version >= '3.5'
mdit-py-plugins==0.3.3 ; python_version >= '3.7'
mdurl==0.1.2 ; python_version >= '3.7'
multidict==6.0.4 ; python_version >= '3.7'
nest-asyncio==1.5.6 ; python_version >= '3.5'
ninja==1.11.1
numpy==1.24.3
orjson==3.8.12 ; python_version >= '3.7'
packaging==23.1 ; python_version >= '3.7'
pandas==2.0.1 ; python_version >= '3.8'
parso==0.8.3 ; python_version >= '3.6'
pickleshare==0.7.5
pillow==9.5.0 ; python_version >= '3.7'
platformdirs==3.5.1 ; python_version >= '3.7'
prompt-toolkit==3.0.38 ; python_full_version >= '3.7.0'
psutil==5.9.5 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pure-eval==0.2.2
pydantic==1.10.7 ; python_version >= '3.7'
pydub==0.25.1
pygments==2.15.1 ; python_version >= '3.7'
pyparsing==3.0.9 ; python_full_version >= '3.6.8'
pyrsistent==0.19.3 ; python_version >= '3.7'
python-dateutil==2.8.2 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'
python-multipart==0.0.6 ; python_version >= '3.7'
pytz==2023.3
pywin32==306 ; sys_platform == 'win32' and platform_python_implementation != 'PyPy'
pyyaml==6.0 ; python_version >= '3.6'
pyzmq==25.0.2 ; python_version >= '3.6'
requests==2.30.0 ; python_version >= '3.7'
semantic-version==2.10.0 ; python_version >= '2.7'
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'
sniffio==1.3.0 ; python_version >= '3.7'
stack-data==0.6.2
starlette==0.27.0 ; python_version >= '3.7'
termcolor==2.3.0 ; python_version >= '3.7'
toolz==0.12.0 ; python_version >= '3.5'
tornado==6.3.2 ; python_version >= '3.8'
tqdm==4.65.0
traitlets==5.9.0 ; python_version >= '3.7'
typing-extensions==4.5.0 ; python_version >= '3.7'
tzdata==2023.3 ; python_version >= '2'
uc-micro-py==1.0.2 ; python_version >= '3.7'
urllib3==2.0.2 ; python_version >= '3.7'
uvicorn==0.22.0 ; python_version >= '3.7'
wcwidth==0.2.6
websockets==11.0.3 ; python_version >= '3.7'
widgetsnbextension==4.0.7 ; python_version >= '3.7'
yarl==1.9.2 ; python_version >= '3.7'
torch 2.0.1+cu118
torchaudio 2.0.2+cu118
torchvision 0.15.2+cu118
are you running the colab.ipynb locally? you should use for local env
python gradio_app.py
are you running the colab.ipynb locally
yes
and executing this python gradio_app.py
in terminal (in the virtual environment), gives the same error
These are steps I did:
py -m venv venv
pip install pipenv
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 #my nvcc version relate to this torch version
pipenv install #another libs except torch and torchvision
Is there any mistake?
I have no idea what it causes too. I use conda personally, therefore I would recommend to use conda. For your python venv, could you try to install all requirements via
pip install -r requirements.txt
this is verified that works on remote google colab notebook.
ok, btw, if you have a workable environment with torch installed correctly, I think you can simply use it directly and install the missing packages.
We have very loose requirements for the package versions, so that most of your existing packages could remain unchanged.
I got the same questions!
I guess it is because of the C++ version.
I download the latest Visual Studio and add the cl into the system pathway. But in other issues, they use VS2019 or sth instead.
So I am still confused with this error
I got the same questions! I guess it is because of the C++ version. I download the latest Visual Studio and add the cl into the system pathway. But in other issues, they use VS2019 or sth instead. So I am still confused with this error
@wanghdUT
Which environment did you use? python env or conda?
I try to re-setup the virtual env using conda and it works,
It seems like conda env handle all visual runtime, dlls, and compiler things
ok, btw, if you have a workable environment with torch installed correctly, I think you can simply use it directly and install the missing packages.
We have very loose requirements for the package versions, so that most of your existing packages could remain unchanged.
@Zeqiang-Lai
when we install torch instantly without specify which version, it'll install the latest version 2.x of torch and it doesn't support conv2d_gradfix. However the program will still running but not using gpu computation I guess.
Do you have a solution for the probelm"ImportError: DLL load failed while importing fused:"now?