本次安装过程中未禁用nouveau驱动,最终结果也成功了。环境搭建主要针对Ubuntu18.04系统
备份原来源:sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
本文使用的vim编辑器,vim的安装以及简单的使用方法参考vim的安装和简单使用
更换源: sudo vim /etc/apt/sources.list
,将下边的阿里源复制进去:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
重启:sudo reboot
更新源:sudo apt-get update
更新软件(可省略):sudo apt-get upgrade
首先输入:ubuntu-drivers devices
提示出现no-free,所推荐的版本为440非免费,如果安装的话会在后续配置中出现缺少依赖,因此建议安装最新版本的free驱动,如下图所示。
添加图形驱动程序到源列表::sudo add-apt-repository ppa:graphics-drivers/ppa
更新:sudo apt-get update
获取信息:ubuntu-drivers devices
截至(2020.8.9,RTX2080TI最新的版本驱动是450)
安装所需要的依赖
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
安装驱动:sudo ubuntu-drivers autoinstall
安装完重启:sudo reboot
查看显卡信息的命令:nvidia-smi
出现上述信息即为驱动安装成功
最高支持cuda-11,但是最新版稳定性不够。
首先找到驱动对应cuda的版本:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/
输入命令下载cuda-10.1:
wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
安装:sudo sh cuda_10.1.243_418.87.00_linux.run
安装完成出现以下结果,说明安装成功。
添加环境变量:
打开文件:vim .bashrc
在文件的最后位置复制一下内容:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64
export PATH=$PATH:/usr/local/cuda-10.1/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.1
输入source ~/.bashrc
,使配置生效。
测试CUDA安装成功的Samples例子:
cd /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
Result = pass则是安装成功
输入命令:nvcc –V
下载cudnn-10.1-linux-x64-v7.6.5.32.tgz:百度云的下载链接
提取码:t79s
先对下载的内容进行解压:
tar –zxvf cudnn-10.1-linux-x64-v7.6.5.32.tgz
输入以下命令:
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*
重启:sudo reboot
检测安装是否成功:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
Ubuntu 18.04.1已经安装了python3.6
下载安装pip:sudo apt-get install python3-pip
更新pip:sudo pip3 install --upgrade pip
下载库:sudo -H pip3 install xxxx
通过使用清华镜像下载最新版本的GPU:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow –U
测试:
import tensorflow as tf
tf.test.is_gpu_available()
最后结果出现True即为安装成功。