Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The code fails to run under Anaconda environment #1

Closed
ycjungSubhuman opened this issue Sep 8, 2021 · 1 comment
Closed

The code fails to run under Anaconda environment #1

ycjungSubhuman opened this issue Sep 8, 2021 · 1 comment

Comments

@ycjungSubhuman
Copy link
Collaborator

ycjungSubhuman commented Sep 8, 2021

! WARNING !!

Environment

Anaconda environment under Arch Linux.
Python = 3.7 with other requirements with matching versions specified in the README.
(Pytorch=1.3.1)

Steps I took

Run the test.py with

python test.py --ckpt checkpoint/StyleCariGAN/001000.pt --input_dir examples/samples --output_dir examples/results --invert_images

Expectation

The code should run without error

What I get

The code fails to run and I get this error message.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Your compiler (c++) is not compatible with the compiler Pytorch was
built with for this platform, which is g++ on linux. Please
use g++ to to compile your extension. Alternatively, you may
compile PyTorch from source using c++, and then you can also use
c++ to compile your extension.

See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help
with compiling PyTorch from source.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                          !! WARNING !!

platform=sys.platform))
Traceback (most recent call last):
File "test.py", line 10, in
from invert import *
File "/home/ycjung/Downloads/git/StyleCariGAN/invert.py", line 12, in
from exaggeration_model import StyleCariGAN
File "/home/ycjung/Downloads/git/StyleCariGAN/exaggeration_model.py", line 7, in
from model import PixelNorm, EqualLinear, ConstantInput, StyledConv, ToRGB, ExaggerationLayer
File "/home/ycjung/Downloads/git/StyleCariGAN/model.py", line 13, in
from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
File "/home/ycjung/Downloads/git/StyleCariGAN/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "/home/ycjung/Downloads/git/StyleCariGAN/op/fused_act.py", line 15, in
os.path.join(module_path, "fused_bias_act_kernel.cu"),
File "/home/ycjung/.conda/envs/stylecarigan/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 661, in load
is_python_module)
File "/home/ycjung/.conda/envs/stylecarigan/lib/python3.7/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/ycjung/.conda/envs/stylecarigan/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1052, in _import_module_from_library
return imp.load_module(module_name, file, path, description)
File "/home/ycjung/.conda/envs/stylecarigan/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/ycjung/.conda/envs/stylecarigan/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/ycjung/.conda/envs/stylecarigan/lib/python3.7/site-packages/torch/../../../libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /tmp/torch_extensions/fused/fused.so)

Analysis

The testing code internally invokes g++ and compiles external modules in op/, which contains several cpp and cu files. The invoked g++ is installed on your system and is probably new (In my case it was 11.1.0). The g++ used for compiling PyTorch 1.3.1 in anaconda environment is old and does not produce binaries compatible with the external module compiled with the new g++.

Troubleshooting

It seems libtorch.so in pytorch/pytorch package is compiled with GCC 7.3.1. So install GCC 7.3.0 in your anaconda environment. (7.3.1 is not in anaconda)

conda install -c anaconda gxx_linux-64=7.3.0

Then run the code with environment variables specifying GCC compilers installed in the conda environment

CC=x86_64-conda_cos6-linux-gnu-gcc CXX=x86_64-conda_cos6-linux-gnu-g++ python test.py --ckpt checkpoint/StyleCariGAN/001000.pt --input_dir examples/custom --output_dir examples/results --invert_images

This solution got the code running fine. I hope it does to your environment!

@ycjungSubhuman
Copy link
Collaborator Author

I don't think this issue requires further discussion. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant