open-mmlab / mmgeneration

MMGeneration is a powerful toolkit for generative models, based on PyTorch and MMCV.
https://mmgeneration.readthedocs.io/en/latest/
Apache License 2.0
1.91k stars 232 forks source link

RuntimeError: fused_bias_leakyrelu_op_impl: implementation for device cuda:0 not found. #489

Closed xxLoadxx closed 1 year ago

xxLoadxx commented 1 year ago

Thanks for your error report and we appreciate it a lot.

Describe the bug 安装配置环境的时候出错,当运行到 fake_imgs = sample_unconditional_model(model, 4) 报错

Reproduction

  1. What command or script did you run?
# 指定 config配置文件路径
config_file = 'configs/styleganv2/stylegan2_c2_lsun-church_256_b4x8_800k.py'

# 指定预训练模型权重文件路径
checkpoint_file = 'https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-church-config-f-official_20210327_172657-1d42b7d1.pth'

# 初始化generatvie
model = init_model(config_file, checkpoint_file, device='cuda:0')

# 生成图像测试
fake_imgs = sample_unconditional_model(model, 4)
  1. Did you make any modifications on the code or config? Did you understand what you have modified? 没有
  2. What dataset did you use? 教程中自带的

Environment

>>> torch.__version__
'1.11.0+cu113'

>>> torchvision.__version__
'0.12.0+cu113'

>>> torchaudio.__version__
'0.11.0+cu113'

>>> mmcv.__version__
'1.7.0'
  1. Please run python mmgen/utils/collect_env.py to collect necessary environment information and paste it here.
    
    /home/load/.local/lib/python3.10/site-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
    warnings.warn(
    sys.platform: linux
    Python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
    CUDA available: True
    CUDA_HOME: None
    GPU 0: NVIDIA GeForce RTX 3060 Laptop GPU
    GCC: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
    PyTorch: 1.11.0+cu113
    PyTorch compiling details: PyTorch built with:
    - GCC 7.3
    - C++ Version: 201402
    - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
    - Intel(R) MKL-DNN v2.5.2 (Git Hash a9302535553c73243c632ad3c4c80beec3d19a1e)
    - OpenMP 201511 (a.k.a. OpenMP 4.5)
    - LAPACK is enabled (usually provided by MKL)
    - NNPACK is enabled
    - CPU capability usage: AVX2
    - CUDA Runtime 11.3
    - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
    - CuDNN 8.2
    - Magma 2.5.2
    - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.11.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

TorchVision: 0.12.0+cu113 OpenCV: 4.6.0 MMCV: 1.7.0 MMGen: 0.7.2+d1039e0 MMCV Compiler: GCC 11.3 MMCV CUDA Compiler: not available

3. You may add addition that may be helpful for locating the problem, such as
   - How you installed PyTorch \[e.g., pip, conda, source\]
   - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
      echo $PATH 
      /home/load/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

**Error traceback**
If applicable, paste the error trackback here.

```none
Traceback (most recent call last):
  File "/home/load/exe.py", line 24, in <module>
    fake_imgs = sample_unconditional_model(model, 4)
  File "/home/load/.local/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/load/mmgeneration/mmgen/apis/inference.py", line 80, in sample_unconditional_model
    res = model.sample_from_noise(
  File "/home/load/mmgeneration/mmgen/models/gans/base_gan.py", line 167, in sample_from_noise
    outputs = _model(noise, num_batches=num_batches, **kwargs)
  File "/home/load/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/load/mmgeneration/mmgen/core/runners/fp16_utils.py", line 142, in new_func
    return old_func(*args, **kwargs)
  File "/home/load/mmgeneration/mmgen/models/architectures/stylegan/generator_discriminator_v2.py", line 372, in forward
    styles = [self.style_mapping(s) for s in styles]
  File "/home/load/mmgeneration/mmgen/models/architectures/stylegan/generator_discriminator_v2.py", line 372, in <listcomp>
    styles = [self.style_mapping(s) for s in styles]
  File "/home/load/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/load/.local/lib/python3.10/site-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/home/load/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/load/mmgeneration/mmgen/models/architectures/stylegan/modules/styleganv2_modules.py", line 108, in forward
    x = self.activate(x, self.bias * self.lr_mul)
  File "/home/load/.local/lib/python3.10/site-packages/mmcv/ops/fused_bias_leakyrelu.py", line 264, in fused_bias_leakyrelu
    return FusedBiasLeakyReLUFunction.apply(input, bias.to(input.dtype),
  File "/home/load/.local/lib/python3.10/site-packages/mmcv/ops/fused_bias_leakyrelu.py", line 169, in forward
    out = ext_module.fused_bias_leakyrelu(
RuntimeError: fused_bias_leakyrelu_op_impl: implementation for device cuda:0 not found.
LeoXing1996 commented 1 year ago

Hi @xxLoadxx, it seems like mmcv-full was not installed successfully. Please refer to this issue.