yuval-alaluf / SAM

Official Implementation for "Only a Matter of Style: Age Transformation Using a Style-Based Regression Model" (SIGGRAPH 2021) https://arxiv.org/abs/2102.02754

Home Page:https://yuval-alaluf.github.io/SAM/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: No module named 'fused'

Tony00728 opened this issue · comments

Sorry for disturbing you.I tried to find many ways to change it, but i still have the problem of "No module named 'fused' ",Can you help me?

Here are system specs:
CUDA Version: 11.3
Pytorch :1.7.1
Ubuntu: 20.04
GPU: nvidia 2080ti
print(torch.cuda.is_available()) is True.

I'll try to testing first.
Terminal-------------------------------
(sam) tony@tony-System-Product-Name:~/SAM-master$ python /home/tony/SAM-master/scripts/inference.py --exp_dir=/home/tony/SAM-master/experiment/ --checkpoint_path=/home/tony/SAM-master/pretrained_models/sam_ffhq_aging.pt --data_path= /home/tony/SAM-master/CelebAMask-HQ/test_img/ --test_batch_size=2 --test_workers=1 --couple_outputs --target_age=0,10,20,30,40,50,60,70,80

Traceback (most recent call last):
File "/home/tony/SAM-master/scripts/inference.py", line 19, in
from models.psp import pSp
File "./models/psp.py", line 12, in
from models.encoders import psp_encoders
File "./models/encoders/psp_encoders.py", line 8, in
from models.stylegan2.model import EqualLinear
File "./models/stylegan2/model.py", line 7, in
from models.stylegan2.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
File "./models/stylegan2/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "./models/stylegan2/op/fused_act.py", line 13, in
os.path.join(module_path, 'fused_bias_act_kernel.cu'),
File "/home/tony/anaconda3/envs/sam/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 997, in load keep_intermediates=keep_intermediates)
File "/home/tony/anaconda3/envs/sam/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1213, in _jit_compile
return _import_module_from_library(name, build_directory, is_python_module)
File "/home/tony/anaconda3/envs/sam/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1560, in _import_module_from_library
file, path, description = imp.find_module(module_name, [path])
File "/home/tony/anaconda3/envs/sam/lib/python3.7/imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)

ImportError: No module named 'fused'

Are you using the conda environment provided with the repo? You should use the conda provided here since it relies on ninja to compile some of the StyleGAN-related layers. This seems to be what is causing the issues here.

Thanks for the author's reply.
I used the anaconda environment provided by repo at the beginning, but something went wrong, so now I changed it to ninja version is 1.10.2, pytorch version is 1.7.1 ,python version is 3.7.
So it's my ninja version problem ?

Seems like it. Have your tried using the conda environment provided in the repo? This should resolve all your problems.