Ubuntu 16.04安装 cuda 9.2

0x00 前言

之前在Ubuntu 16.04上安装了[cuda 9.1],工作也很正常。但是,后来莫名奇妙就出问题了,重装cuda之后还总是进不了系统。因此,寻找到了以下优化的安装方法。

0x01 安装步骤

主要优化点:将之前使用cuda中自带的GPU驱动改为手动安装

以下操作都在root权限下执行:

1、 安装GPU驱动

更新源

  1. add-apt-repository ppa:graphics-drivers/ppa
  2. apt update
COPY

检查当前最佳驱动版本

  1. root@vm:~# ubuntu-drivers devices
  2. == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
  3. modalias : pci:v000010DEd000011C0sv00001458sd0000354Ebc03sc00i00
  4. vendor : NVIDIA Corporation
  5. model : GK106 [GeForce GTX 660]
  6. driver : nvidia-390 - third-party free
  7. driver : nvidia-384 - third-party free
  8. driver : nvidia-396 - third-party free recommended
  9. driver : xserver-xorg-video-nouveau - distro free builtin
  10. driver : nvidia-340 - third-party free
  11. driver : nvidia-304 - third-party free
COPY

可以看出,目前推荐的驱动版本是nvidia-396

  1. apt install nvidia-396
COPY

几分钟后安装完成,使用nvidia-smi命令测试驱动安装是否成功

  1. root@vm:~# nvidia-smi
  2. Fri May 18 09:18:28 2018
  3. +-----------------------------------------------------------------------------+
  4. | NVIDIA-SMI 396.24 Driver Version: 396.24 |
  5. |-------------------------------+----------------------+----------------------+
  6. | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
  7. | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
  8. |===============================+======================+======================|
  9. | 0 GeForce GTX 660 Off | 00000000:01:00.0 N/A | N/A |
  10. | 57% 57C P0 N/A / N/A | 1871MiB / 1994MiB | N/A Default |
  11. +-------------------------------+----------------------+----------------------+
  12. +-----------------------------------------------------------------------------+
  13. | Processes: GPU Memory |
  14. | GPU PID Type Process name Usage |
  15. |=============================================================================|
  16. | 0 Not Supported |
  17. +-----------------------------------------------------------------------------+
COPY

2、安装cuda 9.2

点击链接https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal,下载cuda安装程序到本地。

如果本地安装,可以按Ctrl + Alt + F1进入命令行模式;如果是远程访问,可以使用ssh连接过去。

  1. systemctl stop lightdm
COPY

使用上面的命令关闭桌面服务

  1. chmod 755 cuda_9.2.88_396.26_linux.run
  2. ./cuda_9.2.88_396.26_linux.run
COPY

运行下载下来的安装文件

  1. Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.26?
  2. (y)es/(n)o/(q)uit:
COPY

除了驱动项选择no,其它使用默认值即可

0x02 后记

如果下次又出现驱动无法使用,或进不了系统的情况,只要重新安装一下驱动即可,不需要重新安装cuda

分享

Related Issues not found

Please contact @drunkdream to initialize the comment