项目场景:
编译文件时报错(make.sh setup.py)
问题描述
@问题一:
from /home/a/2022/YZM/VMFormer/models/ops/src/cpu/ms_deform_attn_cpu.cpp:14:0:
/home/a/anaconda3/envs/vmformer/lib/python3.7/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:30: fatal error: cuda_runtime_api.h: 没有那个文件或目录
@问题二:
/bin/sh: 1: /usr/local/cuda-10.2/lib64/bin/nvcc: not found
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/a/anaconda3/envs/vmformer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1672, in _run_ninja_build
env=env)
File "/home/a/anaconda3/envs/vmformer/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1
原因分析:
@错误1:找不到cuda文件
fatal error: cuda_runtime_api.h: 没有那个文件或目录
@错误2:找不到nvcc
/bin/sh: 1: /usr/local/cuda-10.2/lib64/bin/nvcc: not found
解决方案:
vim ~/.bashrc
# 可以根据自己需求进行修改
export CPATH=/usr/local/cuda-10.2/targets/x86_64-linux/include:$CPATH
#export LD_LIBRARY_PATH=/usr/local/cuda-10.2/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-10.2/lib64"
export PATH=/usr/local/cuda-10.2/bin:$PATH
#export PATH="$PATH:/usr/local/cuda-10.2/bin/nvcc"
更新
source ~/.bashrc
解决问题二, 执行了以下代码后可以找到nvcc
export CUDA_HOME="/usr/local/cuda-10.2"
博客链接:http://www.young.ml/