Skip to content

DLL load failed #12

Closed
Closed
@marwanmusa

Description

@marwanmusa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions