XingangPan / DragGAN

Official Code for DragGAN (SIGGRAPH 2023)
https://vcai.mpi-inf.mpg.de/projects/DragGAN/
Other
35.76k stars 3.45k forks source link

Setting up PyTorch plugin "bias_act_plugin"... Failed! #106

Open whateverThisIs opened 1 year ago

whateverThisIs commented 1 year ago

Trying to run the demo on windows11 but got errors for the bias_act_plugin. Seems to be related to cuda and compiler, but have no idea how to solve these. Anyone familiar with these issues? Or should I just throw my windows laptop into a trash can and learn to use linux.

`(draggan) D:\dragGAN>python visualizer_drag_gradio.py File under cache_dir (./checkpoints): ['stylegan2-car-config-f.pkl', 'stylegan2-cat-config-f.pkl', 'stylegan2_dogs_1024_pytorch.pkl', 'stylegan2_elephants_512_pytorch.pkl.pkl', 'stylegan2_horses_256_pytorch.pkl', 'stylegan2_lions_512_pytorch.pkl'] Valid checkpoint file: {'stylegan2-car-config-f': './checkpoints\stylegan2-car-config-f.pkl', 'stylegan2-cat-config-f': './checkpoints\stylegan2-cat-config-f.pkl', 'stylegan2_dogs_1024_pytorch': './checkpoints\stylegan2_dogs_1024_pytorch.pkl', 'stylegan2_elephants_512_pytorch': './checkpoints\stylegan2_elephants_512_pytorch.pkl.pkl', 'stylegan2_horses_256_pytorch': './checkpoints\stylegan2_horses_256_pytorch.pkl', 'stylegan2_lions_512_pytorch': './checkpoints\stylegan2_lions_512_pytorch.pkl'}Loading "./checkpoints\stylegan2_lions_512_pytorch.pkl"... Done. () {'z_dim': 512, 'c_dim': 0, 'w_dim': 512, 'img_resolution': 512, 'img_channels': 3, 'mapping_kwargs': {'num_layers': 8, 'embed_features': None, 'layer_features': None, 'activation': 'lrelu', 'lr_multiplier': 0.01, 'w_avg_beta': 0.995}, 'synthesis_kwargs': {'channel_base': 32768, 'channel_max': 512, 'num_fp16_res': 0, 'conv_clamp': None, 'architecture': 'skip', 'resample_filter': [1, 3, 3, 1], 'use_noise': True, 'activation': 'lrelu'}} Setting up PyTorch plugin "bias_act_plugin"... Failed! Traceback (most recent call last): File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py", line 1893, in _run_ninja_build subprocess.run( File "C:\Users\user1\miniconda3\envs\draggan\lib\subprocess.py", line 528, 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 "D:\dragGAN\visualizer_drag_gradio.py", line 200, in global_state = init_images(global_state) File "D:\dragGAN\visualizer_drag_gradio.py", line 70, in init_images state['renderer'].init_network( File "D:\dragGAN\viz\renderer.py", line 249, in init_network w = G.mapping(z, label, truncation_psi=trunc_psi, truncation_cutoff=trunc_cutoff) File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "D:\dragGAN\training\networks_stylegan2.py", line 247, in forward x = layer(x) File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl return forward_call(args, **kwargs) File "D:\dragGAN\training\networks_stylegan2.py", line 125, in forward x = bias_act.bias_act(x, b, act=self.activation) File "D:\dragGAN\torch_utils\ops\bias_act.py", line 84, in bias_act if impl == 'cuda' and x.device.type == 'cuda' and _init(): File "D:\dragGAN\torch_utils\ops\bias_act.py", line 41, in _init _plugin = custom_ops.get_plugin( File "D:\dragGAN\torch_utils\custom_ops.py", line 136, in get_plugin torch.utils.cpp_extension.load(name=module_name, build_directory=cached_build_dir, File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py", line 1284, in load return _jit_compile( File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py", line 1509, in _jit_compile _write_ninja_file_and_build_library( File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py", line 1624, in _write_ninja_file_and_build_library _run_ninja_build( File "C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py", line 1909, 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\v12.1\bin\nvcc --generate-dependencies-with-compile --dependency-output bias_act.cuda.o.d -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:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\torch\csrc\api\include" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\TH" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\THC" "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include" "-IC:\Users\user1\miniconda3\envs\draggan\Include" -D_GLIBCXX_USE_CXX11_ABI=0 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_BFLOAT16_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --use_fast_math --allow-unsupported-compiler -c "C:\Users\user1\AppData\Local\torch_extensions\torch_extensions\Cache\py39_cu118\bias_act_plugin\3cb576a0039689487cfba59279dd6d46-nvidia-geforce-rtx-3080\bias_act.cu" -o bias_act.cuda.o C:/Users/user1/miniconda3/envs/draggan/lib/site-packages/torch/include\c10/macros/Macros.h(138): warning C4067: unexpected tokens following preprocessor directive - expected a newline C:/Users/user1/miniconda3/envs/draggan/lib/site-packages/torch/include\c10/macros/Macros.h(138): warning C4067: unexpected tokens following preprocessor directive - expected a newline bias_act.cu tmpxft_00000d20_00000000-10_bias_act.cudafe1.cpp

[2/3] cl /showIncludes -DTORCH_EXTENSION_NAME=bias_act_plugin -DTORCH_API_INCLUDE_EXTENSION_H "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\torch\csrc\api\include" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\TH" "-IC:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\include\THC" "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include" "-IC:\Users\user1\miniconda3\envs\draggan\Include" -D_GLIBCXX_USE_CXX11_ABI=0 /MD /wd4819 /wd4251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /EHsc -c "C:\Users\user1\AppData\Local\torch_extensions\torch_extensions\Cache\py39_cu118\bias_act_plugin\3cb576a0039689487cfba59279dd6d46-nvidia-geforce-rtx-3080\bias_act.cpp" /Fobias_act.o Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30137 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

[3/3] "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin/link.exe" bias_act.o bias_act.cuda.o /nologo /DLL c10.lib c10_cuda.lib torch_cpu.lib torch_cuda.lib -INCLUDE:?warp_size@cuda@at@@YAHXZ torch.lib "/LIBPATH:C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\lib" torch_python.lib "/LIBPATH:C:\Users\user1\miniconda3\envs\draggan\libs" "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\lib\x64" cudart.lib /out:bias_act_plugin.pyd FAILED: bias_act_plugin.pyd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin/link.exe" bias_act.o bias_act.cuda.o /nologo /DLL c10.lib c10_cuda.lib torch_cpu.lib torch_cuda.lib -INCLUDE:?warp_size@cuda@at@@YAHXZ torch.lib "/LIBPATH:C:\Users\user1\miniconda3\envs\draggan\lib\site-packages\torch\lib" torch_python.lib "/LIBPATH:C:\Users\user1\miniconda3\envs\draggan\libs" "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\lib\x64" cudart.lib /out:bias_act_plugin.pyd Creating library bias_act_plugin.lib and object bias_act_plugin.exp MSVCRT.lib(loadcfg.obj) : error LNK2001: unresolved external symbol __enclave_config MSVCRT.lib(loadcfg.obj) : error LNK2001: unresolved external symbol __volatile_metadata bias_act_plugin.pyd : fatal error LNK1120: 2 unresolved externals ninja: build stopped: subcommand failed. `

zhangxl296 commented 1 year ago

Try this one ,it works for me.

C:/"Program Files"/"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat python visualizer_drag_gradio.py

MeterLong commented 1 year ago

CUDA11.2以上,GCC最好在9.3.1-9.4.0之间,可以跑起来,亲测

whateverThisIs commented 1 year ago

Try this one ,it works for me.

C:/"Program Files"/"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat python visualizer_drag_gradio.py

thanks for the reply. I tried this but still getting compiler related issue it seems.

whateverThisIs commented 1 year ago

Try this one ,it works for me.

C:/"Program Files"/"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat python visualizer_drag_gradio.py

Actually I got this to work. Uninstalled all my legacy VS and installed 2022 version, then run the bat file. Used pytoch 2.01 and cudatoolkit 11.1 in conda, and installed cuda 11.8 system wide.

Dev000-8 commented 1 year ago

I had the same problem. It now works perfectly in the following environments: OS: Windows 11 Python: 3.8 Visual Studio: 2019 Professional Cuda: 7.5 Torch:2.0.0 GPU:GTX1660

hope this helps someone

mberman84 commented 1 year ago

How did you install cudatoolkit 11.1...that version doesn't seem to be available via conda.

AlexxB31 commented 1 year ago

Try this one ,it works for me.

C:/"Program Files"/"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat python visualizer_drag_gradio.py

Hello, when I run vcvars64.bat only the window opens for a few seconds and draws a single line: ".. initialized for x64" and closes so fast that I even can't read the few words or type anything myself. I have reinstalled twice Visual Studio latest version on Windows 10 and can open it normally.

So how can I run then a command there? Or should the command executed somewhere else? I have already spent 2 days with installing dragGAN and it is always giving the error "Import Error: DLL load failed while importing bias act plugin. Module not found", which is frustrating after so much time.

When I execute the command "visualizer_draggradio.py" within the DragGAN folder prompt window, I get the same error as before, just immediatley without opening the GUI: "File "<frozen importlib._bootstrap<", line 573, in module_from_spec .... Import Error: DLL load failed while importing bias_actr_plugin: Module not found._"

SYSTEM: Windows 10, Pytorch version: 2.1.0 Cuda: 11.8 (Nvidia Graphics card) Cudatoolkit: release 12.1 (v12.1.105) Python: 3.11.5 packaged by Anaconda Visual Studio 2022 (17.7.6) Community Edition

Thanks for help