solution 1 (recommand)
# 直接移除这个驱动(备份出来)
mv /lib/modules/3.0.0-12-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/3.0.0-12-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko.org
# 更新来禁用nouvea
sudo update-initramfs -u
# 重启
sudo reboot
# 查看版本
cat /proc/version
solution 2
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
# 在该文件后添加一下几行:
blacklist nouveau
options nouveau modeset=0
# 更新来禁用nouvea
sudo update-initramfs -u
# 重启
sudo reboot
solution 3
# 如果不允许修改,修改属性命令
sudo chmod 666 /etc/modprobe.d/.d/blacklist.conf
# 用gedit编辑器打开blacklist.conf
sudo gedit /etc/modprobe.d/blacklist.conf
# 在该文件后添加一下几行:
blacklist rivafb
blacklist vga16fb
blacklist nouveau
blacklist nvidiafb
blacklist rivatv
# 更新来禁用nouveau
sudo update-initramfs -u
# 重启
sudo reboot
sudo apt-get remove --purge nvidia*
sudo sh ./驱动名.run --uninstall
solution1 apt安装(recommand)
# search the recommand driver, 384 is recommanded for my PC
sudo ubuntu-drivers devices
# install driver
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-384 nvidia-settings
reboot
nvidia-smi
# 安装Nvidia Prime 双显卡切换指示器
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install prime-indicator
solution2 手动安装
sudo /etc/init.d/gdm stop # 或者 sudo service lightdm stop
sudo chmod +x NVIDIA**.run
sudo sh ./驱动名.run -no-x-check -no-nouveau-check -no-opengl-files
sudo /etc/init.d/gdm start # 或者 sudo service lightdm start
nvidia-smi
nvidia-settings
lspci|grep VGA
lsmod|grep nvidia
cat /proc/driver/nvidia/version
sudo lshw -c video
solution1(recommend)
若是使用深度学习框架,强烈推荐使用anaconda。用conda安装tensorflow/pytorch的GPU版本时,会自动安装相应版本的cuda、cudnn,安全可靠还方便。若想使用不同版本的cuda,只需创建一个新的conda 虚拟环境,重新安装即可。可参考https://blog.csdn.net/DreamLike_zzg/article/details/88575308
solution2 手动安装
cuda8.0 https://developer.nvidia.com/cuda-80-ga2-download-archive
# choose and download :(local)deb Base Installer for Ubuntu
# cd Downloads
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
# after installation, open the bashrc
sudo gedit ~/.bashrc
# the following configure should be added in bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
# active
source ~/.bahsrc
# check cuda version
cat /usr/local/cuda/version.txt
# test
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
sudo ./deviceQuery
cuda9.0 https://developer.nvidia.com/cuda-toolkit-archive
安装第一个cuda时Installer Type无所谓,但安装第二个cuda时建议选择runfile[local]
# 安装相关依赖
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
# 运行runfile文件
sudo sh cuda_9.0.176_384.81_linux.run
#..一堆协议说明...,直接按q退出协议说明.
Do you accept the previously read EULA?: accept/decline/quit: accept #接受协议
You are attempting to install on an unsupported configuration. Do you wish to continue?
((y)es/(n)o) [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
y)es/(n)o/(q)uit: n #是否显卡驱动包,由于已经安装显卡驱动,选择n
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y #是否安装工具包,选择y
Enter Toolkit Location [default is /usr/local/cuda-8.0]: #工具包安装地址,默认回车即可
/usr/local/cuda-9.0 is not writable.
Do you wish to run the installation with ‘sudo’? ((y)es/(n)o): y
Please enter your password:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y #添加链接,指定该链接后会将cuda指向这个新的版本,如果你之前安装过另一个版本的cuda,除非你确定想要用这个新版本的cuda,否则这里就建议选no,
Install the CUDA 9.0 Samples? (y)es/(n)o/(q)uit: y #安装样例,我默认到了home下
Enter CUDA Samples Location [ default is /root ]: #样例安装地址默认即可
Installing the CUDA Toolkit in /usr/local/cuda-9.0 …
Installing the CUDA Samples in /home/xxx …
Copying samples to /home/xxx/NVIDIA_CUDA-9.0_Samples now…
Finished copying samples.
安装完成后,symbolic link:/usr/local/cuda 指向 /usr/local/cuda-9.0。
切换cuda时,重新建立软连接
sudo rm -rf cuda
sudo ln -s /usr/local/cuda-9.0 /usr/local/cuda
查看当前cuda版本
cat /usr/local/cuda/version.txt
安装 cuda-toolkit
sudo apt install nvidia-cuda-toolkit
nvcc --version
cuda与cudnn关系:https://www.jianshu.com/p/622f47f94784
删除原有cudnn,直接终端输入
sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
下载cudnn
download 4 files: https://developer.nvidia.com/rdp/cudnn-archive
cuDNN v7.1.4 Library for Linux
cuDNN v7.1.4 Runtime Library for Ubuntu16.04 (Deb)
cuDNN v7.1.4 Developer Library for Ubuntu16.04 (Deb)
cuDNN v7.1.4 Code Samples and User Guide for Ubuntu16.04 (Deb)
解压安装包
# cd ~/Downloads
tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz
sudo dpkg -i libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.1.4.18-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-doc_7.1.4.18-1+cuda9.0_amd64.deb
# cd ~/Downloads # cudnn-9.0-linux-x64-v7.1.tgz的解压路径
# 安装
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64
sudo chmod +r libcudnn.so.7.0.5
sudo ln -sf libcudnn.so.7.0.5 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so
sudo ldconfig
# test an example
sudo cp -r /usr/src/cudnn_samples_v7/ $HOME
cd $HOME/cudnn_samples_v7/mnistCUDNN
sudo make
./mnistCUDNN # success if print the "Result = PASS" and the information of your GPU
查看当前cudnn version
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2