tensorflow with gpu 環境配置

一、準備工做

1.1 確保GPU驅動已經安裝

lspci | grep -i nvidia 經過此命令能夠查看GPU信息,測試機已經安裝GPU驅動
nvidia-smi 能夠查看英偉達顯卡信息

1.2 確保gcc安裝

能夠經過gcc -v 查看,若是沒有安裝須要安裝

1.3 確保安裝open-ssh

若是沒有安裝能夠經過 yum install openssh-server 安裝
1.4 確保安裝kernel
 sudo yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)

二、安裝CUDA工具包

To use TensorFlow with NVIDIA GPUs, the first step is to install the  CUDA Toolkit.
備註:測試機選用的是 CUDA 8.0,不要使用9.x 有坑

三、安裝GPU加速器cuDNN

安裝完CUDA就能夠安裝  cuDNN .
備註:這個地方要選用與CUDA版本匹配的加速器;測試機選用的是: Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0,安裝步驟以下圖所示:

四、安裝或更新pip(若是有須要的話,若是已經有了,能夠選擇性跳過)

TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated:
$ sudo apt-get install python-pip python-dev
$ pip install --upgrade pip

五、安裝TensorFlow

Run the following command to install the TensorFlow Python package using pip:
$ pip install --upgrade tensorflow-gpu

六、測試安裝是否成功

To test the installation, open an interactive Python shell and import the TensorFlow module:
 
(shan) root@ VM-241-228-ubuntu:/data/shan# python
Python 3.5.3 (default, Jun 23 2017, 16:12:41)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> sess = tf.Session()
2017-07-12 19:24:14.030098: I tensorflow/stream_executor/cuda/ cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-07-12 19:24:14.030833: I tensorflow/core/common_runtime/gpu/ gpu_device.cc:940] Found device 0 with properties:
name: Tesla M40 24GB
major: 5 minor: 2 memoryClockRate (GHz) 1.112
pciBusID 0000:00:06.0
Total memory: 22.40GiB
Free memory: 22.29GiB
2017-07-12 19:24:14.030855: I tensorflow/core/common_runtime/gpu/ gpu_device.cc:961] DMA: 0
2017-07-12 19:24:14.030867: I tensorflow/core/common_runtime/gpu/ gpu_device.cc:971] 0: Y
2017-07-12 19:24:14.030882: I tensorflow/core/common_runtime/gpu/ gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla M40 24GB, pci bus id: 0000:00:06.0)
>>> hello_world = tf.constant("Hello, TensorFlow!")
>>> print (sess.run(hello_world))
b'Hello, TensorFlow!'
>>> print (sess.run(tf.constant(123)*tf.constant(456)))
56088
>>>
參考連接
相關文章
相關標籤/搜索