当前位置:   article > 正文

新装操作系统Ubuntu18.04上安装NVIDIA驱动、CUDA、CUDNN_nvidia driver ubuntu1804-440.33.01 run

nvidia driver ubuntu1804-440.33.01 run

1. NVIDIA显卡驱动

过程不难,就是命令记不住。。。

  1. 驱动下载

官网下载NVIDIA-Linux-x86_64-440.44.run

  1. 卸载nouveau

编辑配置文件

$ sudo vi /etc/modprobe.d/blacklist.conf  
  • 1

添加一行

blacklist nouveau 
  • 1

配置生效

sudo update-initramfs -u  
  • 1

重启电脑检查禁用,若无输出则禁用成功

lsmod | grep nouveau
  • 1
  1. 安装依赖
$ sudo apt-get install gcc make
  • 1
  1. 禁用X服务
$ sudo /etc/init.d/lightdm stop
  • 1
  1. 安装驱动
$ sudo chmod a+x NVIDIA-Linux-x86_64-440.44.run
$ sudo ./NVIDIA-Linux-x86_64-440.44.run
  • 1
  • 2
  1. 检查安装
$ nvidia-smi
Wed Aug 12 14:56:44 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.44       Driver Version: 440.44       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1070    Off  | 00000000:01:00.0  On |                  N/A |
| 51%   36C    P8    10W / 180W |   1085MiB /  8118MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1755      G   /usr/lib/xorg/Xorg                           478MiB |
|    0      3312      G   /opt/teamviewer/tv_bin/TeamViewer              2MiB |
|    0      3398      G   /usr/bin/gnome-shell                         263MiB |
|    0      6194      G   ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files   181MiB |
|    0      6834      G   ...quest-channel-token=3054035920459279912    78MiB |
|    0     10301      G   /usr/local/sunlogin/bin/sunloginclient         5MiB |
|    0     10536      G   /usr/local/sunlogin/bin/sunloginclient        68MiB |
+-----------------------------------------------------------------------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

2. CUDA

  1. 下载安装包,如我的文件是cuda_10.2.89_440.33.01_linux.run

  2. cd到下载目录下执行run文件

$ sudo ./cuda_10.2.89_440.33.01_linux.run
  • 1

下图输入accept执行下一步

选择安装项,Enter键是选择或取消,注意Driver不需要再安装,真正有用的只有第二个CUDA Toolkit。这里其他示例、文档也选择了安装。

出现下面内容表示安装成功

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-10.2/
Samples:  Installed in /home/dreamdeck/, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-10.2/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-10.2/lib64, or, add /usr/local/cuda-10.2/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-10.2/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-10.2/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 440.00 is required for CUDA 10.2 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 /var/log/cuda-installer.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  1. 更改环境变量
$ sudo gedit ~/.bashrc
  • 1

添加以下内容

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
  • 1
  • 2

保存文件后激活环境变量

$ source ~/.bashrc
  • 1
  1. 更改软链接文件

一般情况下上面过程会报错下面内容

/sbin/ldconfig.real: /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7 is not a symbolic link
  • 1

首先检查该文件,下面的输出表明它是一个文件,它本应是一个软连接。

$ ls -lh /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7
-rwxr-xr-x 1 root root 439M 91 11:55 /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7
  • 1
  • 2

于是创建软接连:

sudo ln -sf /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7.6.5 /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7
  • 1

3. CUDNN

  1. 下载与CUDA版本对应的cudnn文件,我的文件是cudnn-10.2-linux-x64-v7.6.5.32.tgz
  2. 解压缩安装
$ tar -zxvf cudnn-10.2-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
  • 1
  • 2
  • 3
  • 4
  1. 查看cudnn版本
$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

上面输出表示我的CUDNN版本是7.6.5


【码字不易,点个赞再走呗!(^ - ^)】

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/211285
推荐阅读
相关标签
  

闽ICP备14008679号