编译neural_renderer_pytorch需要一致的gcc和g++版本,服务器没有root权限,只能在anaconda下更改gcc和g++版本。
升级gcc到7.3.0
conda install -c moussi gcc_impl_linux-64
升级gxx到7.3.0
conda install -c moussi gxx_impl_linux-64
修改gcc软链接
ln -s ~/anaconda3/envs/(envs_name)/bin/x86_64-conda_cos6-linux-gnu-gcc ~/anaconda3/envs/(envs_name)/bin/gcc
修改g++软链接
ln -s ~/anaconda3/envs/(envs_name)/libexec/gcc//bin/x86_64-conda_cos6-linux-gnu-g++ ~/anaconda3/envs/(envs_name)/bin/g++
此时查看gcc与g++版本
gcc -v
Reading specs from ~/anaconda3/envs/(envs_name)/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=~/anaconda3/envs/(envs_name)/bin/../libexec/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-conda_cos6-linux-gnu
Configured with: /home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=x86_64-conda_cos6-linux-gnu --prefix=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built --with-sysroot=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built/x86_64-conda_cos6-linux-gnu/sysroot --enable-languages=c,c++,fortran,objc,obj-c++ --with-pkgversion='crosstool-NG 1.23.0.450-d54ae' --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --enable-libsanitizer --enable-libmpx --with-gmp=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-mpfr=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-mpc=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-isl=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built/x86_64-conda_cos6-linux-gnu/sysroot --enable-long-long --enable-default-pie
Thread model: posix
gcc version 7.3.0 (crosstool-NG 1.23.0.450-d54ae)
g++ -v
Reading specs from ~/anaconda3/envs/(envs_name)/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=~/anaconda3/envs/(envs_name)/bin/../libexec/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-conda_cos6-linux-gnu
Configured with: /home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=x86_64-conda_cos6-linux-gnu --prefix=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built --with-sysroot=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built/x86_64-conda_cos6-linux-gnu/sysroot --enable-languages=c,c++,fortran,objc,obj-c++ --with-pkgversion='crosstool-NG 1.23.0.450-d54ae' --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --enable-libsanitizer --enable-libmpx --with-gmp=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-mpfr=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-mpc=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --with-isl=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/.build/x86_64-conda_cos6-linux-gnu/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/conda/feedstock_root/build_artifacts/ctng-compilers_1580517382604/work/gcc_built/x86_64-conda_cos6-linux-gnu/sysroot --enable-long-long --enable-default-pie
Thread model: posix
gcc version 7.3.0 (crosstool-NG 1.23.0.450-d54ae)
进入目录编译
cd neural_renderer_pytorch
python setup.py install
发现报错,报错内容是找不到一些文件
running install
running bdist_egg
running egg_info
writing neural_renderer_pytorch.egg-info/PKG-INFO
writing dependency_links to neural_renderer_pytorch.egg-info/dependency_links.txt
writing top-level names to neural_renderer_pytorch.egg-info/top_level.txt
reading manifest file 'neural_renderer_pytorch.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'neural_renderer_pytorch.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'neural_renderer.cuda.load_textures' extension
Emitting ninja build file /.../neural_renderer_pytorch/build/temp.linux-x86_64-3.6/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
g++ -pthread -shared -B /opt/anaconda1anaconda2anaconda3/compiler_compat -L/opt/anaconda1anaconda2anaconda3/lib -Wl,-rpath=/opt/anaconda1anaconda2anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ /.../neural_renderer_pytorch/build/temp.linux-x86_64-3.6/neural_renderer/cuda/load_textures_cuda.o /.../neural_renderer_pytorch/build/temp.linux-x86_64-3.6/neural_renderer/cuda/load_textures_cuda_kernel.o -L~/anaconda3/envs/(envs_name)/lib/python3.6/site-packages/torch/lib -L/usr/local/cuda-10.2/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-3.6/neural_renderer/cuda/load_textures.cpython-36m-x86_64-linux-gnu.so
~/anaconda3/envs/(envs_name)/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find /lib/libpthread.so.0: No such file or directory
~/anaconda3/envs/(envs_name)/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find /usr/lib/libpthread_nonshared.a: No such file or directory
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
查阅资料,找到解决方案 在新环境中构建cython扩展:找不到/lib/libpthread.so.0
conda install gxx_linux-64
conda install cmake
显示编译成功
Installed ~/anaconda3/envs/(envs_name)/lib/python3.6/site-packages/neural_renderer_pytorch-1.1.3-py3.6-linux-x86_64.egg
Processing dependencies for neural-renderer-pytorch==1.1.3
Finished processing dependencies for neural-renderer-pytorch==1.1.3