Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named 'upfirdn2d_plugin' #44

Open
FBehrad opened this issue Oct 23, 2022 · 6 comments
Open

ImportError: No module named 'upfirdn2d_plugin' #44

FBehrad opened this issue Oct 23, 2022 · 6 comments

Comments

@FBehrad
Copy link

FBehrad commented Oct 23, 2022

Hello,
When I run the code, I get the following warnings. I have followed all the steps according to the ReadMe file. Installing VS C++, windows SDK, and other techniques provided on GitHub were not helpful.
I still get a result but the result is not good at all. I attach the input, mask, and the output.

Loading data from: C:\Users\User 2\Downloads\mat input
Loading mask from: C:\Users\User 2\Downloads\mat mask
Loading networks from: pretrained/Places_512_FullData.pkl
Prcessing: indoor1.png
Setting up PyTorch plugin "bias_act_plugin"... Failed!
C:\Users\User 2\PycharmProjects\MAT\torch_utils\ops\bias_act.py:50: UserWarning: Failed to build CUDA kernels for bias_act. Falling back to slow reference implementation. Details:

Traceback (most recent call last):
  File "C:\fatemeh\project\environments\MAT\lib\site-packages\torch\utils\cpp_extension.py", line 1533, in _run_ninja_build
    subprocess.run(
  File "C:\Users\Python\Python38\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\User 2\PycharmProjects\MAT\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\User 2\PycharmProjects\MAT\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 "C:\fatemeh\project\environments\MAT\lib\site-packages\torch\utils\cpp_extension.py", line 986, in load
    return _jit_compile(
  File "C:\fatemeh\project\environments\MAT\lib\site-packages\torch\utils\cpp_extension.py", line 1193, in _jit_compile
    _write_ninja_file_and_build_library(
  File "C:\fatemeh\project\environments\MAT\lib\site-packages\torch\utils\cpp_extension.py", line 1297, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "C:\fatemeh\project\environments\MAT\lib\site-packages\torch\utils\cpp_extension.py", line 1555, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'bias_act_plugin': [1/3] C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcompiler /EHsc -Xcompiler /wd4190 -Xcompiler /wd4018 -Xcompiler /wd4275 -Xcompiler /wd4267 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4819 -Xcompiler /MD -DTORCH_EXTENSION_NAME=bias_act_plugin -DTORCH_API_INCLUDE_EXTENSION_H -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\torch\csrc\api\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\TH -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -IC:\Users\Python\Python38\Include -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=sm_86 --use_fast_math -c "C:\Users\User 2\PycharmProjects\MAT\torch_utils\ops\bias_act.cu" -o bias_act.cuda.o 
FAILED: bias_act.cuda.o 
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcompiler /EHsc -Xcompiler /wd4190 -Xcompiler /wd4018 -Xcompiler /wd4275 -Xcompiler /wd4267 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4819 -Xcompiler /MD -DTORCH_EXTENSION_NAME=bias_act_plugin -DTORCH_API_INCLUDE_EXTENSION_H -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\torch\csrc\api\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\TH -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -IC:\Users\Python\Python38\Include -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=sm_86 --use_fast_math -c "C:\Users\User 2\PycharmProjects\MAT\torch_utils\ops\bias_act.cu" -o bias_act.cuda.o 
nvcc fatal   : Unsupported gpu architecture 'compute_86'
[2/3] cl /showIncludes -DTORCH_EXTENSION_NAME=bias_act_plugin -DTORCH_API_INCLUDE_EXTENSION_H -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\torch\csrc\api\include -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\TH -IC:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -IC:\Users\Python\Python38\Include -D_GLIBCXX_USE_CXX11_ABI=0 /MD /wd4819 /wd4251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /EHsc -c "C:\Users\User 2\PycharmProjects\MAT\torch_utils\ops\bias_act.cpp" /Fobias_act.o 
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

C:\fatemeh\project\environments\MAT\lib\site-packages\torch\include\pybind11\detail/common.h(106): warning C4005: 'HAVE_SNPRINTF': macro redefinition
C:\Users\Python\Python38\Include\pyerrors.h(315): note: see previous definition of 'HAVE_SNPRINTF'
ninja: build stopped: subcommand failed.


  warnings.warn('Failed to build CUDA kernels for bias_act. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc())

I'm usaing :

  • Python 3.7
  • Pytorch 1.7.1
  • Cuda 11.0
  • Windows 10

I wonder what is the role of upfirdn2d_plugin and how it affects the predictions.

@fenglinglwb
Copy link
Owner

I suggest using Conda to install the environment to avoid compilation issues.
As for the visual results, our model cannot handle some cases, not even the most cutting-edge diffusion models. Thus, there is a lot of room for improvement.

@DWiszyns
Copy link

Hi,

I experience the same issue with conda. I'm using:

  • Python 3.7
  • Ubuntu 22.04
  • Cuda 11.0
  • Pytorch 1.7.1

Here is the log I got when I tried to run generate_image:

python generate_image.py --network models/CelebA-HQ_512.pkl --dpath test_sets/CelebA-HQ/images --mpath test_sets/CelebA-HQ/masks --outdir samples
Loading data from: test_sets/CelebA-HQ/images
Loading mask from: test_sets/CelebA-HQ/masks
Loading networks from: models/CelebA-HQ_512.pkl
Prcessing: test1.png
Setting up PyTorch plugin "bias_act_plugin"... Failed!
/home/user/Documents/MAT/torch_utils/ops/bias_act.py:50: UserWarning: Failed to build CUDA kernels for bias_act. Falling back to slow reference implementation. Details:

Traceback (most recent call last):
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1900, in _run_ninja_build
    subprocess.run(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/Documents/MAT/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 "/home/user/Documents/MAT/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 "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1284, in load
    return _jit_compile(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1508, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1623, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1916, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'bias_act_plugin': [1/1] c++ bias_act.o bias_act.cuda.o -shared -L/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/home/user/anaconda3/envs/MAT2/lib64 -lcudart -o bias_act_plugin.so
FAILED: bias_act_plugin.so 
c++ bias_act.o bias_act.cuda.o -shared -L/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/home/user/anaconda3/envs/MAT2/lib64 -lcudart -o bias_act_plugin.so
/usr/bin/ld: cannot find -lcudart: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


  warnings.warn('Failed to build CUDA kernels for bias_act. Falling back to slow reference implementation. Details:\n\n' + traceback.format_exc())
Setting up PyTorch plugin "upfirdn2d_plugin"... Failed!
/home/user/Documents/MAT/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 "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1900, in _run_ninja_build
    subprocess.run(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/Documents/MAT/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 "/home/user/Documents/MAT/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 "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1284, in load
    return _jit_compile(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1508, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1623, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1916, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'upfirdn2d_plugin': [1/1] c++ upfirdn2d.o upfirdn2d.cuda.o -shared -L/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/home/user/anaconda3/envs/MAT2/lib64 -lcudart -o upfirdn2d_plugin.so
FAILED: upfirdn2d_plugin.so 
c++ upfirdn2d.o upfirdn2d.cuda.o -shared -L/home/user/anaconda3/envs/MAT2/lib/python3.8/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/home/user/anaconda3/envs/MAT2/lib64 -lcudart -o upfirdn2d_plugin.so
/usr/bin/ld: cannot find -lcudart: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


  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!
/home/user/Documents/MAT/torch_utils/ops/upfirdn2d.py:34: UserWarning: Failed to build CUDA kernels for upfirdn2d. Falling back to slow reference implementation. Details:

@fenglinglwb
Copy link
Owner

May try re-installing the ninja using conda.

@liawifelix
Copy link

I solve this issue by re-install my cuda to cuda10 and nvidia driver to 470. I'm using ubuntu20 with venv as the virtual environment. Hope it helps you :D

@DWiszyns
Copy link

Yeah when I tried to have cuda 10 I had issues because my gpu wasn't compatible with PyTorch installation. Reinstalling ninja didn't work as well.

@qinghew
Copy link

qinghew commented May 24, 2023

3090, ubuntu meets this issue.
install re2c by:
tar -xvzfre2c-1.0.3.targz
cd re2c-1.0.3/
autoreconf-i-Wall
make
make install

then install ninja by:
git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap
cp ninja /usr/bin/

the current terminal can use ninja

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants