1.显卡驱动430
1)卸载现有驱动:sudo apt-get remove --purge nvidia*
2)安装ppa显卡驱动源:
sudo apt-get updatesudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
3)检查显卡和推荐的驱动
sudo apt-cache search nvidia
ubuntu-drivers devices
结果:
vendor : NVIDIA Corporation
driver : nvidia-driver-418 - third-party free
driver : nvidia-driver-430 - third-party free recommended
driver : xserver-xorg-video-nouveau - distro free builtin
于是步骤:
4)sudo apt-get install nvidia-driver-430
期间可能会设置密码,进行重启后的修改确认“Enroll MOK”
5)重启并检查(输入密码,在“Enroll MOK”中确认修改!)
查看:nvidia-smi:
2.安装cuda10.0(下载链接https://developer.nvidia.com/cuda-toolkit-archive,对比关系图https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html)
1)sudo chmod a+x cuda_xxxxx_linux.run
2)sudo sh cuda_xxxxx_linux.run
中间再安装显卡驱动时,要NO,其他都是YES或者default
3)成功后,修改配置文件sudo vim ~/.bashrc
4)添加语句并保存:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
或者可以为:
export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
5)source ~/.bashrc
测试:
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
sudo ./deviceQuery
或者:nvcc--version
连接:sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
3.cudnn7.6.1(下载链接https://developer.nvidia.com/rdp/cudnn-download)
1)解压tar zxvf FileName.tgz
2)将文件倒入相关内容中
sudo cp cudnn.h /usr/local/cuda/include/
sudo cp lib* /usr/local/cuda/lib64/
3)动态文件进行链接
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.7 #删除原有动态文件
sudo ln -s libcudnn.so.7.6.1 libcudnn.so.7 #生成软衔接
sudo ln -s libcudnn.so.7 libcudnn.so #生成软链接
4.安装pip,进行安装其他依赖库
sudo apt-get install python3-pip
之后pip install opencv-python numpy scipy sklearn
5.安装tensorflow-gpu
首先确认自己安装的版本,因为相互之间的对应关系https://tensorflow.google.cn/install/source#linux
pip install tensorflow-gpu或者pip install tensorflow-gpu==1.xx
pip install keras