在Ubuntu20.04复现PVN3D的时候,编译Pointnet++,已经安装好了依赖,在执行python3 setup.py build_ext的时候报错,首先报错如下:

据我分析,我的显卡是3090,而这个项目要求的Cuda版本是10.2,torch用的1.5,gcc用的7,所以我认为是算力过高,加入以下命令:
export TORCH_CUDA_ARCH_LIST="7.5"
这个报错解决,但是出现新的报错:

/usr/local/cuda-10.2/bin/nvcc -I/home/ubuntu/anaconda3/envs/cppn/lib/python3.8/site-packages/torch/include -I/home/ubuntu/anaconda3/envs/cppn/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/ubuntu/anaconda3/envs/cppn/lib/python3.8/site-packages/torch/include/TH -I/home/ubuntu/anaconda3/envs/cppn/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/ubuntu/anaconda3/envs/cppn/include/python3.8 -c ./pvn3d/_ext-src/src/ball_query_gpu.cu -o build/temp.linux-x86_64-cpython-38/./pvn3d/_ext-src/src/ball_query_gpu.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -O2 -I./pvn3d/_ext-src/include -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14
cc1plus: error: unrecognized command line option ‘-fstack-clash-protection’
cc1plus: error: unrecognized command line option ‘-fcf-protection’
error: command '/usr/local/cuda-10.2/bin/nvcc' failed with exit code 1
这个真的百思不得其解,我在Ubuntu18.04复现的时候就没有这个问题,目前猜测是20.04的某些东西自动喂给了gcc这两个参数
麻烦不要用AI模型回答我!
serup.py的内容如下:
#!/usr/bin/env python3
import os
import glob
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
_ext_src_root = "./pvn3d/_ext-src"
_ext_sources = glob.glob("{}/src/*.cpp".format(_ext_src_root)) + glob.glob(
"{}/src/*.cu".format(_ext_src_root)
)
_ext_headers = glob.glob("{}/include/*".format(_ext_src_root))
setup(
name='pvn3d',
ext_modules=[
CUDAExtension(
name='pointnet2_utils._ext',
sources=_ext_sources,
extra_compile_args={
"cxx": ["-O2", "-I{}".format("{}/include".format(_ext_src_root))],
"nvcc": [
"-O2", "-I{}".format("{}/include".format(_ext_src_root))
],
},
)
],
cmdclass={
'build_ext': BuildExtension
}
)
try:
src_pth = './build'
tg_pth = 'pvn3d/lib/pointnet2_utils/'
fd_lst = os.listdir(src_pth)
for fd in fd_lst:
if 'lib' in fd:
src_pth = os.path.join(src_pth, fd, 'pointnet2_utils')
f_nm = os.listdir(src_pth)[0]
src_pth = os.path.join(src_pth, f_nm)
tg_pth = os.path.join(tg_pth, f_nm)
os.system('cp {} {}'.format(src_pth, tg_pth))
print(
src_pth, '==>', tg_pth,
)
except:
print(
"\n****************************************************************\n",
"Failed to copy builded .so to ./pvn3d/lib/pointnet2_utils/.\n",
"Please manually copy the builded .so file (_ext.cpython*.so) in ./build"+\
" to ./pvn3d/lib/pointnet2_utils/.",
"\n****************************************************************\n"
)
# vim: ts=4 sw=4 sts=4 expandtab