stylegan2-pytorch: no module named fused error

Hi, I prepared the dataset and run the train.py as you said in the readme but got into a problem regrading the cpp extention.

Traceback (most recent call last): File "train.py", line 20, in <module> from model import Generator, Discriminator File "/data/llh/projects/stylegan2/model.py", line 11, in <module> from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d File "/data/llh/projects/stylegan2/op/__init__.py", line 1, in <module> from .fused_act import FusedLeakyReLU, fused_leaky_relu File "/data/llh/projects/stylegan2/op/fused_act.py", line 6, in <module> fused = load('fused', sources=['op/fused_bias_act.cpp', 'op/fused_bias_act_kernel.cu']) File "/home/llh/miniconda3/envs/py3pt11/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 644, in load is_python_module) File "/home/llh/miniconda3/envs/py3pt11/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 824, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File "/home/llh/miniconda3/envs/py3pt11/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 967, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File "/home/llh/miniconda3/envs/py3pt11/lib/python3.6/imp.py", line 297, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named 'fused'

any idea?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

I try to run the code on 4 different environment. Check ~/.cache/torch_extensions/fused: If success, ~/.cache/torch_extensions/fused will include build.ninja fused_bias_act_kernel.cuda.o fused_bias_act.o fused.so If faild, ~/.cache/torch_extensions/fused will include only build.ninja

Then, you can go into ~/.cache/torch_extensions/fused and run ninja, ninja will try to build fused.so, there will be errors (maybe include important things to solve this problem) Maybe caused by ninja or gcc? I’m checking…

Update: (Passed): Environment 1 with gcc 7.5.0 (Passed): Environment 2 with gcc 5.2.0 (Failed): Environment 3 with gcc 9.4.0

/usr/local/cuda-9.0/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  119 | #error -- unsupported GNU version! gcc versions later than 6 are not supported!
      |  ^~~~~
ninja: build stopped: subcommand failed.

(Failed): Environment 4 with gcc 4.9.3

 #error "You're running a too old version of GCC. We need GCC 5 or later."

Update: (Failed->Passed): Environment 3 with gcc 9.4.0 and g++ 5.5.0 -> gcc 5.5.0 and g++ 5.5.0

If success, ~/.cache/torch_extensions/fused will include build.ninja fused_bias_act_kernel.cuda.o fused_bias_act.o fused.so If faild, ~/.cache/torch_extensions/fused will include only build.ninja

Then, you can go into ~/.cache/torch_extensions/fused and run ninja, ninja will try to build fused.so, there will be errors (maybe include important things to solve this problem)

Thank you very much! You solved my problem perfectly!!!

i have a same problem,torch 1.3.1,cuda10.1,what do you mean by “check you can build custom extensions”?can you explain in detail. thx Traceback (most recent call last): File “generate.py”, line 5, in <module> from model import Generator File “/data/zeta/zeta/model.py”, line 11, in <module> from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d File “/data/zeta/zeta/op/init.py”, line 1, in <module> from .fused_act import FusedLeakyReLU, fused_leaky_relu File “/data/zeta/zeta/op/fused_act.py”, line 15, in <module> os.path.join(module_path, “fused_bias_act_kernel.cu”), File “/home/momobot/anaconda3/envs/train/lib/python3.6/site-packages/torch/utils/cpp_extension.py”, line 661, in load is_python_module) File “/home/momobot/anaconda3/envs/train/lib/python3.6/site-packages/torch/utils/cpp_extension.py”, line 841, in _jit_compile return _import_module_from_library(name, build_directory, is_python_module) File “/home/momobot/anaconda3/envs/train/lib/python3.6/site-packages/torch/utils/cpp_extension.py”, line 1048, in _import_module_from_library file, path, description = imp.find_module(module_name, [path]) File “/home/momobot/anaconda3/envs/train/lib/python3.6/imp.py”, line 297, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named ‘fused’

@zhanghp96 First you need to check you can build custom extensions. (You can refer to this: https://github.com/pytorch/extension-cpp) Then you can clean /tmp/torch_extensions/fused and retry.