新系统先装驱动
sudo add-apt-repository ppa:graphics-drivers/ppa (添加软件源,2系列显卡用 或者装418最新版显卡驱动用这命令, 否则不用执行这个)
sudo apt-get update
sudo ubuntu-drivers autoinstall
重启:reboot
开机检查安装成功:nvidia-smi
安装cuda10.0
这里使用从官网的.run文件安装
sudo chmod 777 cuda_10.0.130_410.48_linux.run
sudo sh cuda_10.0.130_410.48_linux.run (accept、n、y、""、y、y、"")
Do you accept the previously read EULA? accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48? n
Install the CUDA 10.0 Toolkit? y
Enter Toolkit Location “Enter”
Do you want to install a symbolic link at /usr/local/cuda? y
Install the CUDA 10.0 Samples? y
Enter CUDA Samples Location “Enter”
添加环境变量:终端输入 sudo gedit ~/.bashrc 打开环境变量文件 将变量添加到文件底部
export PATH=$PATH:/usr/local/cuda-10.0/bin
export LD_LIBARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.0
保存并退出 source ~/.bashrc
测试是否安装成功:上面的选项选择安装了CUDA例子,运行其中一个来测试是否安装成功:
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
安装CUDNN
在官网下载安装包,需要注册登录才能下载。选择适合自己的版本
下载完成后解压并进入文件夹:
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
在终端查看CUDNN版本:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
STEP6:添加cudnn软连接 终端输入5行命令
sudo cp /usr/local/cuda-10.0/lib64/libcudart.so.10.0 /usr/local/lib/libcudart.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcublas.so.10.0 /usr/local/lib/libcublas.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcurand.so.10.0 /usr/local/lib/libcurand.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcudnn.so.7 /usr/local/lib/libcudnn.so.7 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcusolver.so.10.0 /usr/local/lib/libcusolver.so.10.0 && sudo ldconfig
sudo cp /usr/local/cuda-10.0/lib64/libcufft.so.10.0 /usr/local/lib/libcufft.so.10.0 && sudo ldconfig
安装opencv (3版本)
opencv安装需要用cmake编译,需要先下载cmake;新系统自带的源是定位不到camke的,所用还要先换源
备份系统配置
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
编辑配置
sudo gedit /etc/apt/sources.list
修改内容如下(适用于Ubuntu16.04、18.04)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
修改完保存,进行更新
sudo apt-get update
另一种cmake的也可以本地安装参考:https://www.cnblogs.com/yibeimingyue/p/11921788.html
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=Release -D WITH_GTK=ON CMAKE_INSTALL_PREFIX=/usr/local ..
#cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_FFMPEG=OFF ..
make
sudo make install
安装Qt
./qt-opensource-linux-x64-5.14.1.run
使用cmake构建项目时报错:Failed to find “GL/gl.h” in “/usr/include/libdrm”
sudo apt install mesa-common-dev
error while loading shared libraries: libmyelin.so.1
还需要修改cuda的链接库
PS:不然使用Tensorrt的libmyelin.so.1.0.0会报错cudnn.so库的一些错误
cd /usr/local/cuda-10.0/lib64
sudo rm -rf libcudnn.so.7 libcudnn.so
sudo ln -s libcudnn.so.7.6.3 libcudnn.so.7
sudo ln -s libcudnn.so.7 libcudnn.so
cd /usr/local/cuda/lib64
sudo rm -rf libcudnn.so.7 libcudnn.so
sudo ln -s libcudnn.so.7.6.3 libcudnn.so.7
sudo ln -s libcudnn.so.7 libcudnn.so
cd /usr/local/lib
# sudo rm -rf licudnn.so.7 这个可以不需要删除
sudo rm -rf libcudnn.so.7
sudo cp /usr/local/cuda-10.0/lib64/libcudnn.so.7 /usr/local/lib/libcudnn.so.7 && sudo ldconfig
Pylon
cd /opt/
sudo mkdir pylon
cd pylon/
sudo cp ~/pylon_6.1.1.19861_x86_64_setup.tar.gz .
sudo tar -zxvf pylon_6.1.1.19861_x86_64_setup.tar.gz
sudo tar -C /opt/pylon -xzf ./pylon_6.1.1.19861_x86_64.tar.gz
sudo chmod 777 /opt/pylon -R
Tensonrrt报错:error while loading shared libraries: libmyelin.so.1
操作:代码由C编写,gcc编译通过,以管理员权限运行,出错
sudo gedit /etc/ld.so.conf
末尾新一行追加
/home/reebow/TensorRT-7.0.0.11/targets/x86_64-linux-gnu/lib
/home/reebow/TensorRT-7.0.0.11/lib
/usr/local/cuda-10.0/lib64
保存退出
以管理员权限执行 ldconfig 命令
/usr/bin/ld: 找不到 -lnvinfer
cd /home/reebow/TensorRT-7.0.0.11/lib/stubs
sudo cp libnvinfer.so /usr/local/lib/