1.NVIDIA显卡驱动安装
先到英伟达官网上下载与你的显卡对应的显卡驱动。下载链接:https://www.nvidia.cn/Download/index.aspx?lang=cn
下载之后是某一个.run的文件:
NVIDIA-Linux-x86_64-430.14.run
查看是否有NVIDIA的显卡:
lspci | grep -i nvidia
uname -m && cat /etc/*release
有信息则说明显卡插好了:
23:00.0 VGA compatible controller: NVIDIA Corporation Device 1b82 (rev a1)
23:00.1 Audio device: NVIDIA Corporation Device 10f0 (rev a1)
如果之前有旧的显卡驱动需要先卸载:
sudo apt-get remove nvidia-*
sudo apt-get autoremove
- Uninstall the drivers from the .run file
sudo nvidia-uninstall
Ctrl+Alt+F1
cd Downloads
sudo service lightdm stop
chmod +x NVIDIA-Linux-x86_64-430.14.run
sudo ./NVIDIA-Linux-x86_64-430.14.run -no-x-check -no-nouveau-check -no-opengl-files
其中:
- -no-x-check安装驱动时关闭x服务
- -no-nouveau-check 安装驱动时禁用Nouveau
- -no-opengl-files 安装时只装驱动文件,不安装Opengl
sudo service lightdm restart
重启之后发现屏幕分辨率改变则表示显卡驱动安装成功!
2.安装CUDA
如果之前你有安装CUDA,换了新的显卡之后无法正常使用,则需要卸载CUDA,没有安装的话直接跳过这一步:
sudo /usr/local/cuda-8.0/bin/uninstall_cuda_8.0.pl
sudo rm -rf /usr/local/cuda-8.0/
可以在官网,下载我们需要的CUDA版本。
下载好了之后给予文件执行权限:
cd Downloads
chmod +x cuda_9.0.176_384.81_linux.run
打开终端,cd 到这个文件夹下,然后安装:
sudo ./cuda_9.0.176_384.81_linux.run
开始安装之后,需要阅读说明,可以使用Ctrl + C直接阅读完成,或者使用空格键慢慢阅读。然后进行配置,这里说明一下:
(是否同意条款,必须同意才能继续安装)
accept/decline/quit: accept
(这里不要安装驱动,因为已经安装最新的驱动了,否则可能会安装旧版本的显卡驱动,导致重复登录的情况)
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: n
Install the CUDA 9.0 Toolkit?(是否安装CUDA 9 ,这里必须要安装)
(y)es/(n)o/(q)uit: y
Enter Toolkit Location(安装路径,使用默认,直接回车就行)
[ default is /usr/local/cuda-9.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?(同意创建软链接)
(y)es/(n)o/(q)uit: y
Install the CUDA 9.0 Samples?(不用安装测试,本身就有了)
(y)es/(n)o/(q)uit: n
Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...(开始安装)
结果:
Installing the CUDA Toolkit in /usr/local/cuda-9.0 ...
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-9.0
Samples: Not Selected
Please make sure that
- PATH includes /usr/local/cuda-9.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-9.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run -silent -driver
Logfile is /tmp/cuda_install_15999.log
Signal caught, cleaning up
这里注意默认目录最好不要改,容易给后续操作带来不便。最后,需要将CUDA添加到环境变量中,添加方法如下:
sudo gedit ~/.bashrc
在文件末尾添加下面代码并保存:
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH
之后更新环境变量:
source ~/.bashrc
3.安装CUDNN
传送们:在Ubuntu16.04更换cudnn版本
参考:https://blog.csdn.net/qq_31148431/article/details/86606144
|