eladrich / pixel2style2pixel

Official Implementation for "Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation" (CVPR 2021) presenting the pixel2style2pixel (pSp) framework
https://eladrich.github.io/pixel2style2pixel/
MIT License
3.19k stars 570 forks source link

RuntimeError: No CUDA GPUs are available #68

Closed Emmanuel357 closed 3 years ago

Emmanuel357 commented 3 years ago

I am facing below error when importing psp class module from models.psp

No CUDA runtime is found, using CUDA_HOME='/usr'
Traceback (most recent call last):
  File "run.py", line 5, in <module>
    from models.psp import pSp
  File "/home/emmanuel/Downloads/pixel2style2pixel-master/models/psp.py", line 9, in <module>
    from models.encoders import psp_encoders
  File "/home/emmanuel/Downloads/pixel2style2pixel-master/models/encoders/psp_encoders.py", line 8, in <module>
    from models.stylegan2.model import EqualLinear
  File "/home/emmanuel/Downloads/pixel2style2pixel-master/models/stylegan2/model.py", line 7, in <module>
    from models.stylegan2.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
  File "/home/emmanuel/Downloads/pixel2style2pixel-master/models/stylegan2/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/emmanuel/Downloads/pixel2style2pixel-master/models/stylegan2/op/fused_act.py", line 9, in <module>
    fused = load(
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 986, in load
    return _jit_compile(
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1193, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1285, in _write_ninja_file_and_build_library
    _write_ninja_file_to_build_library(
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1635, in _write_ninja_file_to_build_library
    cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags()
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1424, in _get_cuda_arch_flags
    capability = torch.cuda.get_device_capability()
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 291, in get_device_capability
    prop = get_device_properties(device)
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 296, in get_device_properties
    _lazy_init()  # will define _get_device_properties
  File "/home/emmanuel/.local/lib/python3.8/site-packages/torch/cuda/__init__.py", line 172, in _lazy_init
    torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available
``

Do I need a gpu inother to use the models?

yuval-alaluf commented 3 years ago

Yes. To run our training and inference code you need a GPU install on your machine. In case this is not an option, you can consider using the Google Colab notebook we provided to help get you started.

Emmanuel357 commented 3 years ago

Isn't there a way that I should be able to disable gpu usage?

yuval-alaluf commented 3 years ago

Currently no. StyleGAN relies on several components (e.g. FusedLeakyRelu) whose compilation requires GPU. However, please see Issue #18 for more details on what changes you can make to try running inference on CPU.
Please note that training on CPU will not be practical.

Emmanuel357 commented 3 years ago

Do you know any native implementation for upfirdn2d.py?

yuval-alaluf commented 3 years ago

Do you know any native implementation for upfirdn2d.py?

Please see my comment here: https://github.com/eladrich/pixel2style2pixel/issues/18#issuecomment-715910467