运行StyleGAN2时遇NVCC编译错误及未定义符号问题求助
StyleGAN2运行报错及解决求助
初始错误:TensorFlow符号未找到
运行StyleGAN2时触发以下错误:
NotFoundError: /home/chengjun/stylegan2-master/dnnlib/tflib/_cudacache/fused_bias_act_347e82e8919aeb0d5c7dc989e996c091.so: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
使用ldd命令检查该.so文件,发现其未链接tensorflow_framework.so.1:
linux-vdso.so.1 (0x00007ffdbe136000) _pywrap_tensorflow_internal.so => not found libstdc++.so.6 => /home/chengjun/anaconda3/lib/libstdc++.so.6 (0x00007f1ba7000000) libgcc_s.so.1 => /home/chengjun/anaconda3/lib/libgcc_s.so.1 (0x00007f1ba72df000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1ba6c00000) /lib64/ld-linux-x86-64.so.2 (0x00007f1ba73d5000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1ba6f19000)
添加路径后出现新的NVCC编译错误
将TensorFlow相关路径添加到bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/python/
再次运行后触发NVCC编译错误:
raise RuntimeError('NVCC returned an error. See below for full command line and output log:\n\n%s\n\n%s' % (cmd, output)) RuntimeError: NVCC returned an error. See below for full command line and output log: nvcc "/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so" --compiler-options '-fPIC -D_GLIBCXX_USE_CXX11_ABI= 0' --gpu-architecture=sm_86 --use_fast_math --disable-warnings --include-path "/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/include" --include-path "/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/include/external/protobuf_archive/src" --include-path "/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/include/external/com_google_absl" --include-path "/home/chengjun/anaconda3/envs/python3/lib/python3.6/site-packages/tensorflow/include/external/eigen_archive" 2>&1 "/home/chengjun/stylegan2-master/dnnlib/tflib/ops/fused_bias_act.cu" --shared -o "/tmp/tmp8e0pgiod/fused_bias_act_tmp.so" --keep --keep-dir "/tmp/tmp8e0pgiod" gcc-11: fatal error: cannot specify ‘-o’ with ‘-c’, ‘-S’ or ‘-E’ with multiple files compilation terminated.
待解决问题
- 上述错误的根本原因是什么?
- 如何修复当前的编译及链接问题?
- 目前即使删除添加的
LD_LIBRARY_PATH路径,错误仍存在,该如何处理?
内容的提问来源于stack exchange,提问作者Chengjun Duan
相关产品推荐
相关产品推荐

