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
https://yuval-alaluf.github.io/SAM/
MIT License
632 stars 151 forks source link

Getting error in compiling code #9

Closed MetiCodePrivateLimited closed 3 years ago

MetiCodePrivateLimited commented 3 years ago

I am trying to execute following command:

python scripts/inference.py \

--exp_dir=/to \ --checkpoint_path=/trained/sam2.pt \ --data_path=/from \ --test_batch_size=4 \ --test_workers=4 \ --couple_outputs \ --target_age=0,10,20,30,40,50,60,70,80

and I got following error:


Traceback (most recent call last): File "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 "/root/anaconda3/envs/sam_env/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 974, in load keep_intermediates=keep_intermediates) File "/root/anaconda3/envs/sam_env/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1179, in _jit_compile with_cuda=with_cuda) File "/root/anaconda3/envs/sam_env/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1251, in _write_ninja_file_and_build_library check_compiler_abi_compatibility(compiler) File "/root/anaconda3/envs/sam_env/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 248, in check_compiler_abi_compatibility if not check_compiler_ok_for_platform(compiler): File "/root/anaconda3/envs/sam_env/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 208, in check_compiler_ok_for_platform which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT) File "/root/anaconda3/envs/sam_env/lib/python3.6/subprocess.py", line 336, in check_output **kwargs).stdout File "/root/anaconda3/envs/sam_env/lib/python3.6/subprocess.py", line 418, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.


Could you help me to fix this error?

yuval-alaluf commented 3 years ago

Based on the stack trace there seems to be some issue with your compiler. What compiler are you using? You may need to update your gcc. If it helps, I have gcc and g++ versions of 7.5.0.

MetiCodePrivateLimited commented 3 years ago

We tried many ways but all in vain. I am showing you all my steps below:

Install ubuntu 1804 gcc and g++ 7.5.0 freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev cuda tookit 10.1 cudnn for cuda 10.1

Set CUDA paths
echo 'export PATH=/usr/local/cuda-10.1/bin:$PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrcsource ~/.bashrc sudo ldconfig

Download Cudnn 7.6.5 for CUDa 10.1
Extract the downloaded file Copy the following files into the CUDA directory
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-10.1/include sudo cp -P cuda/lib64/libcudnn /usr/local/cuda-10.1/lib64/ sudo chmod a+r /usr/local/cuda-10.1/lib64/libcudnn

Download Anaconda file wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh sha256sum https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh bash https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh

git clone SAM conda env create -f sam_env.yaml conda activate sam_env

python scripts/inference.py \ --exp_dir=to \ --checkpoint_path=pretrained_models/sam.pt \ --data_path=from \ --test_batch_size=4 \ --test_workers=4 \ --couple_outputs \ --target_age=0,10,20,30,40,50,60,70,80

I am still getting errors.

yuval-alaluf commented 3 years ago

This is very strange. Everything seems fine to me and yet I've never seen the error you got. Are you guys able to run other things that require CUDA using PyTorch? I believe this could be an issue related to the installation of your CUDA.

MetiCodePrivateLimited commented 3 years ago

Fixed, thanks.