RTX3070安装spconv1.1

系统环境:

torch:1.8.1
cuda:11.1
cudnn:8.0.5
cpu:RTX3070
gcc:7.5.0(g++ 7.5.0,c++14需要g++5.2以上)
cmake:3.18.3(3.13.2及以上)

第一步环境配置

在开始安装前,需要确保已经安装cuda和cudnn。
以及cudnn的版本一定要和cuda的版本对应。
需要注意要将cuda/include/cudnn_version.h文件也移动到/usr/local/cuda/include文件中,
且需要加权限

sudo cp cuda/include/cudnn_version.h /usr/local/cuda/include/
chmod 777 /usr/local/cuda/include/cudnn_version.h

第二步克隆代码

链接为https://github.com/traveller59/spconv/tree/v1.1
我直接下载的zip文件。
安装依赖:

sudo apt-get install libboost-all-dev

执行命令:

python setup.py bdist_wheel

如果cmake不报错,会创建dist目录,生成文件:在这里插入图片描述

第三步报错的解决过程

错误一:

subprocess.CalledProcessError: Command '['cmake', '/home/lu/spconv', '-DCMAKE_PREFIX_PATH=/home/lu/anaconda3/envs/futuredet/lib/python3.7/site-packages/torch', '-DPYBIND11_PYTHON_VERSION=3.7', '-DSPCONV_BuildTests=OFF', '-DCMAKE_CUDA_FLAGS="--expt-relaxed-constexpr"', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/lu/spconv/build/lib.linux-x86_64-cpython-37/spconv', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.

这个错误在github上的issue中给出的解决方案是将cudnn_version.h移动到cuda文件夹下:

sudo cp cuda/include/cudnn_version.h /usr/local/cuda/include/
chmod 777 /usr/local/cuda/include/cudnn_version.h

错误二:

这个错误也是cuda环境配置的问题,

ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name' CMakeFiles/cmTC_686d7.dir/build.make:84: recipe for target 'CMakeFiles/cmTC_686d7.dir/main.cu.o' failed

检查一下~/.bashrc文件中是否有:

export PATH=/usr/local/cuda-11.1/bin:$PATH
export CUDA_ROOT=/usr/local/cuda-11.1
export CUDA_HOME=/usr/local/cuda-11.1
export PATH=$PATH:/usr/local/cuda-11.1/bin    
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH

以及检查/usr/local文件夹下,cuda和cuda-11.1的软链接是否正确:
在这里插入图片描述

错误三:

还有一个错误找不到torch包:

Could not find a package configuration file provided by "Torch" with any of the following names.

这个错误的解决就是忽视它,再次执行python setup.py bdist_wheel就好了。

错误四:

The CUDA compiler "/usr/bin/nvcc" is not able to compile a simple test program.

在CMakeLists.txt文件中添加一句:
set(CMAKE_CUDA_COMPILER “/usr/local/cuda-11.1/bin/nvcc”)
RTX3070安装spconv1.1_第1张图片

错误五:

最后编译到95%的时候开始报这个错误:

error: ‘cout’ is not a member of ‘std’

解决方法是在报错的文件中添加一句:

sudo gedit /home/lu/Downloads/spconv/include/spconv/nms.h
#include

错误六:

ImportError: cannot import name 'spconv_utils' from 'spconv' (/home/lu/Downloads/spconv/spconv/__init__.py)

最后pip安装成功后仍会报这个错误,
解决方法是在~/.barhrc文件中添加一句:
这个路径就是你下载的spconv的路径。

export PYTHONPATH=/home/amy/Documents/spconv/:$PYTHONPATH

你可能感兴趣的:(python,开发语言)