Ubuntu16.04 部署GPU环境

硬件环境

研祥IPC-520S
CPU   I7-7700,8M,3.6GHZ,4核
内存  DDR4  16G
硬盘  SSD 500G
显卡  NVDIA  GeForce GTX1050Ti  4G

准备工作

1.双网卡绑定

root@mec03:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bonding mode=0 miimon=100

root@mec03:/etc/network# cat /etc/network/interfaces
auto bond0
iface bond0 inet static
address 172.30.10.249
netmask 255.255.255.0
gateway 172.30.10.254
post-up ifenslave bond0 enp2s0 enp3s0
pre-down ifenslave -d bond0 enp2s0 enp3s0

root@mec03:/etc/network# modprobe bonding 

2.python3.6及pip3

安装Nvidia GTX 1050Ti 驱动

安装cuda 10.1

安装cuDNN 7.6

root@mec03:~# dpkg -i libcudnn7_7.6.3.30-1+cuda10.0_amd64.deb 
root@mec03:~# dpkg -i libcudnn7-dev_7.6.3.30-1+cuda10.0_amd64.deb 
root@mec03:~# pkg -i libcudnn7-doc_7.6.3.30-1+cuda10.0_amd64.deb

root@mec03:~# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

安装tensorflow-gpu

root@mec03:~# pip3 install tensorflow-gpu==1.13.1

检查效果

zhidao@mec03:~$ nvidia-smi 
Fri Sep  6 19:42:42 2019    
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      9558      C   python3                                     3865MiB |
|    0     12510      G   /usr/lib/xorg/Xorg                            39MiB |
|    0     12608      G   gnome-shell                                   38MiB |
+-----------------------------------------------------------------------------+
Fri Sep  6 00:22:27 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       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 GTX 105...  Off  | 00000000:01:00.0  On |                  N/A |
| 31%   62C    P0    N/A /  80W |   3955MiB /  4038MiB |     97%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      9558      C   python3                                     3865MiB |
|    0     12510      G   /usr/lib/xorg/Xorg                            39MiB |
|    0     12608      G   gnome-shell                                   38MiB |
+-----------------------------------------------------------------------------+