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
>>>
参考连接
相关文章
相关标签/搜索