背景
安装nvidia的MinkowskiEngine库时,报错:“thrust” has no member “device”(其实还有其他错误,这些错误的本质原因是一样的)
# 安装代码
mkdir -p /workspace
cd /workspace
git clone https://github.com/NVIDIA/MinkowskiEngine.git
cd /workspace/MinkowskiEngine
TORCH_CUDA_ARCH_LIST="7.5 8.0 8.9" python3 setup.py install --blas=openblas --force_cuda
原因分析
- 笔者的环境是CUDA12.1
- 错误的原因很简单,cuda版本太新,thrust库的使用发生了变化
- 解决方法很简单:在对应文件中加入需要的头文件,比如src/3rdparty/concurrent_unordered_map.cuh中报标题中的错误,则只需要添加:include <thrust/execution_policy.h>即可
解决方案
mkdir -p /workspace
cd /workspace
git clone https://github.com/NVIDIA/MinkowskiEngine.git
cd /workspace/MinkowskiEngine
# <thrust/execution_policy.h>头文件是解决编译报错问题:error: namespace "thrust" has no member "device"
# <thrust/unique.h>、<thrust/sort.h>是解决类似的问题
sed -i '31i #include <thrust/execution_policy.h>' ./src/convolution_kernel.cuh
sed -i '39i #include <thrust/unique.h>\n#include <thrust/remove.h>' ./src/coordinate_map_gpu.cu
sed -i '38i #include <thrust/execution_policy.h>\n#include <thrust/reduce.h>\n#include <thrust/sort.h>' ./src/spmm.cu
sed -i '38i #include <thrust/execution_policy.h>' ./src/3rdparty/concurrent_unordered_map.cuh
TORCH_CUDA_ARCH_LIST="7.5 8.0 8.9" python3 setup.py install --blas=openblas --force_cuda