fatal error: cuda_runtime_api.h: No such file or directory
添加以下宏
export CUDA_HOME=/usr/local/cuda
export CFLAGS="-I$CUDA_HOME/include $CFLAGS"
export LIBRARY_PATH=$CUDA_HOME/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
arch_list PTX 相关报错:
File "/opt/conda/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1606, in _get_cuda_arch_flags
arch_list[-1] += '+PTX'
IndexError: list index out of range
添加以下宏,例如CUDA11.3
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX"
完整版
if you are building in Nvidia docker container without actual GPU, you can use something like this:
CUDA_VERSION=$(/usr/local/cuda/bin/nvcc --version | sed -n 's/^.*release \([0-9]\+\.[0-9]\+\).*$/\1/p')
if [[ ${CUDA_VERSION} == 9.0* ]]; then
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;7.0+PTX"
elif [[ ${CUDA_VERSION} == 9.2* ]]; then
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0+PTX"
elif [[ ${CUDA_VERSION} == 10.* ]]; then
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5+PTX"
elif [[ ${CUDA_VERSION} == 11.0* ]]; then
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5;8.0+PTX"
elif [[ ${CUDA_VERSION} == 11.* ]]; then
export TORCH_CUDA_ARCH_LIST="3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX"
else
echo "unsupported cuda version."
exit 1
fi
文章主要讨论了在CUDA开发中遇到的fatalerror:cuda_runtime_api.h:Nosuchfileordirectory错误,以及PTX相关报错IndexError:listindexoutofrange。为了解决这些问题,提出了设置环境变量如CUDA_HOME、CFLAGS、LIBRARY_PATH和LD_LIBRARY_PATH的方法,并给出了针对不同CUDA版本的TORCH_CUDA_ARCH_LIST配置示例,特别提到了在无GPU的NvidiaDocker容器中的构建策略。
7934

被折叠的 条评论
为什么被折叠?



