北白川家的氷菓 2024-12-03 15:56 采纳率: 50%
浏览 57
已结题

Ubuntu20.04中PVN3D复现过程交叉编译问题

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

img

据我分析,我的显卡是3090,而这个项目要求的Cuda版本是10.2,torch用的1.5,gcc用的7,所以我认为是算力过高,加入以下命令:


export TORCH_CUDA_ARCH_LIST="7.5"

这个报错解决,但是出现新的报错:

img

/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

  • 写回答

18条回答 默认 最新

  • m0_70915816 2024-12-05 09:29
    关注

    这个问题我也遇到过,可以检查一下你安装的torch是用什么编译的,指令:torch.config.show(),看看使用的gcc和这个版本一样不一样,强烈建议从官网上下载torch,不要用轮子文件编译,问题真的很多。另外这个项目可以用更高版本的torch复现,不一定要用10.2

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(17条)

报告相同问题?

问题事件

  • 系统已结题 12月13日
  • 已采纳回答 12月5日
  • 修改了问题 12月3日
  • 修改了问题 12月3日
  • 展开全部