本文主要是介绍无root权限安装CUDA10.0以及gcc的降级+FairMOT构建DCNv2踩坑记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
无root权限安装CUDA10.0+FairMOT构建DCNv2踩坑记录
首先介绍一下环境情况
因为比赛CUDA版本要求是10.0,所以本文是在Ubuntu20.04下安装CUDA10.0实现FairMOT的复现;但是Ubuntu20.04自带的gcc版本是9.3,创建虚拟环境创建出来的gcc版本根据python版本各异,而在CUDA10.0编译DCNv2要求gcc版本在7以下,所以还需要做一个gcc的版本降级
- NVIDIA-SMI 460.80 Driver Version: 460.80 CUDA Version:11.2
- Ubuntu20.04
- GPU2080Ti
- CUDA10.0
因为使用的是服务器,以用户身份登录是没有root权限的
无root权限安装CUDA
非root用户安装cuda与cudnn
非root用户安装cuda10.0和cudnn
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
gcc版本的降级
非root权限升级(修改当前用户)Linux gcc版本
后来想到我们为什么要那么努力改变主机的gcc版本呢?我们明明是在虚拟环境下运行啊!经过查找发现anaconda创建出来的虚拟环境gcc版本是和主机版本不一致的,我们可以改变anaconda的gcc 版本来运行!!毕竟我们用的是虚拟环境嘛
如何改变anaconda 的 gcc 版本?
最后才发现这么多努力可以只换做一行命令行语句
conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2
通过conda安装gcc5.4.0,它会自动把依赖和环境都给配好
泪目啊
同时因为版本的问题,大大小小把DCNv2的坑全踩了一遍,记录一下
1. 执行FairMOT demo.py出现Error:ModuleNotFoundError: No module named '_ext’
(fairmot) lyp@ubuntu-server:~/FairMOT-master/src$ python demo.py mot --load_model ../models/fairmot_dla34.pth --conf_thres 0.4
Traceback (most recent call last):File "demo.py", line 14, in <module>from track import eval_seqFile "/home/lyp/FairMOT-master/src/track.py", line 15, in <module>from tracker.multitracker import JDETrackerFile "/home/lyp/FairMOT-master/src/lib/tracker/multitracker.py", line 13, in <module>from models.model import create_model, load_modelFile "/home/lyp/FairMOT-master/src/lib/models/model.py", line 11, in <module>from .networks.pose_dla_dcn import get_pose_net as get_dla_dcnFile "/home/lyp/FairMOT-master/src/lib/models/networks/pose_dla_dcn.py", line 16, in <module>from dcn_v2 import DCNFile "/home/lyp/FairMOT-master/DCNv2/dcn_v2.py", line 13, in <module>import _ext as _backend
ModuleNotFoundError: No module named '_ext'
解决措施:
这是一个深度学习代码运行时报的错,错误原因是/DCNv2/目录下需要重新编译,要把该目录的build文件夹(如果存在的话)删除,然后在命令行运行python setup.py build develop重新生成符合自己环境的build
2. nvcc明明在/cuda/bin/目录下却说找不到
unable to execute ':/home/lyp/cuda-10.0/bin/nvcc': No such file or directory
error: command ':/home/lyp/cuda-10.0/bin/nvcc' failed with exit status 1
解决措施:
(fairmot) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ vim ~/.bashrc
改为export CUDA_HOME=/home/lyp/cuda-10.0
(fairmot) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ source ~/.bashrc
3. 由于/bin:/usr/bin 不在PATH 环境变量中,故无法找到该命令。
(base) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ source ~/.bashrc
命令 'dirname' 可在以下位置找到* /bin/dirname* /usr/bin/dirname
由于/bin:/usr/bin 不在PATH 环境变量中,故无法找到该命令。
dirname:未找到命令
命令 'dirname' 可在以下位置找到* /bin/dirname* /usr/bin/dirname
由于/bin:/usr/bin 不在PATH 环境变量中,故无法找到该命令。
dirname:未找到命令
解决措施:
不要改PATH,改的是CUDA_HOME
4. error: ‘THFloatBlas_gemv’ was not declared in this scope;
/home/lyp/FairMOT-master/DCNv2/src/cpu/dcn_v2_cpu.cpp:224:9: error: ‘THFloatBlas_gemv’ was not declared in this scope; did you mean ‘THFloatBlas_axpy’?224 | THFloatBlas_gemv('t', k_, m_, 1.0f,| ^~~~~~~~~~~~~~~~| THFloatBlas_axpy
error: command 'g++' failed with exit status 1
解决措施:
5. 没有root权限,权限不够
(fairmot) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ ./make.sh
-bash: ./make.sh: 权限不够
(fairmot) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ chmod +x ./make.sh
(fairmot) lyp@ubuntu-server:~/FairMOT-master/DCNv2$ ./make.sh
running build
running build_ext
building '_ext' extension
6. #error – unsupported GNU version! gcc versions later than 7 are not supported!
/home/lyp/cuda-10.0/include/crt/host_config.h:129:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!129 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!| ^~~~~
error: command '/home/lyp/cuda-10.0/bin/nvcc' failed with exit status 1
归根到底,还是gcc版本太高了,Ubuntu20.04自带的gcc版本是9.3,现在需要对gcc版本做一个降级
! ! ! ! ! !不要直接将Ubuntu的gcc版本,我们只需要改变anaconda虚拟环境的gcc版本就可以啦 血泪教训
7. gcc: error trying to exec ‘cc1plus’: execvp: no such file or directory
存在问题:
gcc与g++的版本没有对应
解决措施:
conda install https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2
大家如果还有问题可以看看这篇博客FairMOT构建DCNv2踩坑记录
最近又遇到了一个新问题
(redet) lyp@ubuntu-server:~$ bash compile.sh
/home/lyp/anaconda3/envs/redet/compiler_compat/ld: cannot find -lpthread
/home/lyp/anaconda3/envs/redet/compiler_compat/ld: cannot find -lc
collect2: 错误: ld 返回 1
error: command ‘gcc’ failed with exit status 1
解决办法:
https://www.cnblogs.com/zhangly2020/p/14213866.html
这篇关于无root权限安装CUDA10.0以及gcc的降级+FairMOT构建DCNv2踩坑记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!