OpenGVLab / DragGAN

Unofficial Implementation of DragGAN - "Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold" (DragGAN 全功能实现,在线Demo,本地部署试用,代码、模型已全部开源,支持Windows, macOS, Linux)
5k stars 491 forks source link

Failed to build CUDA kernels for upfirdn2d #94

Open LiJT opened 1 year ago

LiJT commented 1 year ago

Failed to build CUDA kernels for upfirdn2d....

`Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\bias_act.py", line 48, in _init _plugin = custom_ops.get_plugin('bias_act_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for bias_act. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Registering hook for: b256 Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Setting up PyTorch plugin "upfirdn2d_plugin"... Failed! C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last): File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\ops\upfirdn2d.py", line 32, in _init _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math']) File "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py", line 64, in get_plugin raise RuntimeError(f'Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "{file}".') RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer. Check _find_compiler_bindir() in "C:\Users\charl\miniconda3\envs\draggan\lib\site-packages\draggan\stylegan2\torch_utils\custom_ops.py".

warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc()) Successfully loaded, starting gradio demo Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch().`

Could you please tell me how to fix this? It runs extremely slow

Zeqiang-Lai commented 1 year ago

As the message say

RuntimeError: Could not find MSVC/GCC/CLANG installation on this computer.

baiyutang commented 1 year ago

+1

baiyutang commented 1 year ago
warnings.warn('Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc())
Setting up PyTorch plugin "upfirdn2d_plugin"... Failed!
/data/anaconda3/envs/draggan/lib/python3.7/site-packages/draggan/stylegan2/torch_utils/ops/upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

Traceback (most recent call last):
  File "/data/anaconda3/envs/draggan/lib/python3.7/site-packages/draggan/stylegan2/torch_utils/ops/upfirdn2d.py", line 32, in _init
    _plugin = custom_ops.get_plugin('upfirdn2d_plugin', sources=sources, extra_cuda_cflags=['--use_fast_math'])
  File "/data/anaconda3/envs/draggan/lib/python3.7/site-packages/draggan/stylegan2/torch_utils/custom_ops.py", line 110, in get_plugin
    torch.utils.cpp_extension.load(name=module_name, verbose=verbose_build, sources=sources, **build_kwargs)
  File "/data/anaconda3/envs/draggan/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1296, in load
    keep_intermediates=keep_intermediates)
  File "/data/anaconda3/envs/draggan/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1534, in _jit_compile
    return _import_module_from_library(name, build_directory, is_python_module)
  File "/data/anaconda3/envs/draggan/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1936, in _import_module_from_library
    module = importlib.util.module_from_spec(spec)
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /root/.cache/torch_extensions/py37_cu117/upfirdn2d_plugin/upfirdn2d_plugin.so: cannot open shared object file: No such file or directory
Jallisto commented 1 year ago

I fixed this RuntimeError for myself today.

However I'm not a professional programmer, so my advice is limited, but I can tell you what I did.

I previously installed Anaconda3, CUDA Toolkit 11.8 and had already Visual Studio 2022 on my computer. Based on various sources (including those provided below) and digging through some of the files, I figured there might be some problem with the current installations of CUDA and Visual Studio. So I uninstalled everything and reinstalled the older versions of CUDA Toolkit 11.7 and Visual Studio 2019. I also removed Anaconda3 en reinstalled Miniconda3 just in case some corrupt files might be left behind. After this the error was gone.

These are the sources I used: Failed to build CUDA kernels for upfirdn2d. UserWarning: Failed to build CUDA kernels for upfirdn2d. #155 Here they give advice to reinstall many components, including the CUDA Toolkit. Some people also recommend using Visual Studio 2019 instead of 2022. Add Windows support for MSVC compiler path search #17 This source recommends adding code to the custom_ops.py file (I tried this, but because I was having other errors as well I'm not sure if it worked and I decided to reinstall everything instead).