Dell server Ubuntu 18.04 dual graphics (2080ti) to build deep learning environment (CUDA 10.1 / cuDNN 7.6 / Tensorflow 1.14) .md

# 1 install the graphics driver

1.1 BIOS to disable Secure Boot

  • Power on the server, by setting F2 to enter Bios
  • In the System BIOS -> System Security -> Secure Boot, select Disabled, save and exit

1.2 Disable third-party drive Nouveau

  • Uninstall previously installed the NVIDIA drivers
$ sudo apt-get purge nvidia*
  • Will be added to the blacklist nouveau
# 编辑blacklist.conf
$ sudo nano /etc/modprobe.d/blacklist.conf
# 在blacklist.conf的文件的最后手动添加:blacklist nouveau
# 更新内核
$ sudo update-initramfs -u
# 重启
reboot
# 重启后验证nouveau是否被禁用,如果下列语句无输出,表示禁用成功
lsmod | grep nouveau

1.3 official website to download drivers

  • Official website address: https://www.geforce.cn/drivers
  • After selecting your video card model and operating system, download the corresponding driver (the current version is: 430.34)

1.4 driver installation

  • Restart the server, enter the command line interface for installation. When the server is rebooted user login interface, press CTRL + ALT + F2 (F2 ~ F6 available, corresponding to different terminals 5, Fl is a graphical interface) into the command line interface
  • Drive into the download directory, start the installation
# 安装gcc make
$ sudo apt-get install gcc make g++
# 给文件增加可执行权限
$ sudo chmod a+x NVIDIA-Linux-x86_64-430.34.run
# 开始安装,后面的那个参数表示不安装OPENGL
$ sudo ./NVIDIA-Linux-x86_64-430.34.run --no-opengl-files
# 安装完成后,重启
$ reboot
# 验证是否安装成功
$ nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.34       Driver Version: 430.34       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| 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 RTX 208...  Off  | 00000000:02:00.0 Off |                  N/A |
| 18%   61C    P0    67W / 250W |      0MiB / 11019MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce RTX 208...  Off  | 00000000:04:00.0 Off |                  N/A |
| 27%   64C    P0     1W / 250W |      0MiB / 11019MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

# 2 install CUDA 10.1

CUDA 2.1 Download the installation file

  • Enter the official website, select the corresponding version of the operating system, it is recommended to download runfile(downloaded deb, but installation fails)

2.2 to perform the installation

  • Go to the download directory, execute the command
# 开始安装
$ sudo sh cuda_10.1.168_418.67_linux.run
# 添加环境变量
$ sudo nano /etc/profile
# 添加以下文本到profile的最后
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# 保存修改,然后更新环境变量
$ source /etc/profile

CUDA 2.3 is installed successfully test

  • CUDA compiler of Sample
cd ~
cp -r /usr/local/cuda-10.1/samples/ .
cd samples/
# make大概要10分钟左右
make
  • Test CUDA
cd ./1_Utilities/deviceQuery
./deviceQuery
# 出现如下类似结果,表示成功
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 2 CUDA Capable device(s)
Device 0: "GeForce RTX 2080 Ti"
  CUDA Driver Version / Runtime Version          10.1 / 10.1
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 11019 MBytes (11554717696 bytes)
  (68) Multiprocessors, ( 64) CUDA Cores/MP:     4352 CUDA Cores
  GPU Max Clock rate:                            1545 MHz (1.54 GHz)
  Memory Clock rate:                             7000 Mhz

# 3 Install cuDNN 7.6

  • Enter the official website to download the file, need to register to download, https://developer.nvidia.com/cudnn
  • CUDA 10.1 corresponding cuDNN is 7.6, select the corresponding version, download the file. As shown below:

  • Installation cuDNN
tar -zxvf cudnn-10.1-linux-x64-v7.6.1.34.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*
  • View cuDNN version
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
# 输出结果如下:
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 1
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

# 4 mounted Anaconda (Python 3.7 version)

$ sudo chmod +x Anaconda3-2019.03-Linux-x86_64.sh
$ sudo bash Anaconda3-2019.03-Linux-x86_64.sh

# 5 安装TensorFlow 1.14(GPU版)

  • 安装TF
# 建议先将conda的源设置为国内的,否则速度太慢
$ conda install tensorflow-gpu==1.14.0

如果出现anaconda3文件无写入权限的问题(EnvironmentNotWritableError: The current user does not have write permissions to the target environment),可以使用命令对文件夹授权。
sudo chown -R user_name /path/to/anaconda3

  • 测试TF
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Guess you like

Origin www.cnblogs.com/robinzh/p/11202732.html