1.查看主机显卡型号:
lspci | grep -i vga
转存失败重新上传取消
下载nvidia对应型号驱动:
https://www.nvidia.com/Download/index.aspx?lang
2.使用yum安装lrzsz组件,便于传文件
yum install -y lrzsz
3.关闭防火墙
service firewalld.service stop
chkconfig firewalld off
4.编辑驱动黑名单:
vim /etc/modprobe.d/dccp-blacklist.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0
vim /usr/lib/modprobe.d/dist-blacklist.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0
6.建立新的镜像
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
dracut /boot/initramfs-$(uname -r).img $(uname -r)
7.查看是否在跑 nouveau默认驱动
lsmod | grep nouveau
8.停止XServer服务
init 3
service lightdm stop
9.给nvidia驱动赋权,并执行
chmod +x nvidia.run
sh nvidia.run --no-opengl-files
10.安装 vncserver 以备远程操作 labelimage.
yum install tigervnc tigervnc-server -y
yum groupinstall -y "Desktop" "X Window System"
11.安装cuda
去官方选择合适的版本下载
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64
选择本地run文件
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
执行安装:
sh cuda_10.2.89_440.33.01_linux.run
加入环境变量
export PATH=/usr/local/cuda-10.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
reboot
测试
nvcc -V
12.安装cuDNN
官方下载对应版本
https://developer.nvidia.com/rdp/cudnn-download
更名
mv cudnn-10.2-linux-x64-v7.6.5.32.solitairetheme8 cudnn.gz
解压缩
tar -vxf cudnn.gz
进入解压缩目录
cd cuda
拷贝到系统对应的目录中
cp include/cudnn.h /usr/local/cuda/include/
cp lib64/libcudnn* /usr/local/cuda/lib64/
chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
删除原软链接
cd /usr/local/cuda/lib64
//删除原来的链接
rm libcudnn.so libcudnn.so.7
//生成新的链接
ln ‐s libcudnn.so.7.4.2 libcudnn.so.7
ln ‐s libcudnn.so.7 libcudnn.so
chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
ldconfig
13.安装OpenCV
官方下载:https://opencv.org/releases/
选择合适版本:
这里我选择3.4.8 https://github.com/opencv/opencv/tree/3.4.8
安装预制软件:
yum -y install epel-release
yum -y install gcc gcc-c++
yum -y install cmake
yum -y install python-devel numpy
yum -y install ffmpeg-devel
编译opencv.
cd opencv
mkdir build
cd build
cmake ..
make
make install
配置opencv:
cd /etc/ld.so.conf.d
添加opencv编译产生的lib库路径到opencv.conf中
/bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
加载 ldconfig
ldconfig
添加PATH
find / -name "opencv.pc"
/usr/local/lib64/pkgconfig/opencv.pc
vim /etc/bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig/
export PKG_CONFIG_PATH
是配置生效:
source /etc/bashrc
更新库
updatedb
pkg-config配置(存在就不需要操作了)
mkdir -p /usr/local/lib/pkgconfig
默认的pkg搜索链接路径/usr/lib/pkgconfig,需要将opencv.pc拷贝到pkg的默认路径下
cp /usr/local/lib64/pkgconfig/opencv.pc /usr/lib/pkgconfig
darknet下载:
git clone https://github.com/pjreddie/darknet
make
开启gpu,opencv,cuda
vim Makefile
GPU=1
CUDNN=1
OPENCV=1
保存后
make clean
make
至此。darknet编译成功。可以开始识别之旅了。