如何在AMD/ATI GPU上运行TensorFlow? [英] How to run TensorFlow on AMD/ATI GPU?

查看:815
本文介绍了如何在AMD/ATI GPU上运行TensorFlow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了本教程之后 https://www.tensorflow.org/guide/using_gpu 我在这个简单的代码上检查了GPU会话

After reading this tutorial https://www.tensorflow.org/guide/using_gpu I checked GPU session on this simple code

import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2,3], name = 'a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape = [3,2], name =  'b')
c = tf.matmul(a, b)

with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as sess:
    x = sess.run(c)
print(x)

输出为

2018-08-07 18:44:59.019144:我 tensorflow/core/platform/cpu_feature_guard.cc:141]您的CPU支持 TensorFlow二进制文件未编译使用的指令:AVX2 FMA设备映射:没有已知的设备. 2018-08-07 18:44:59.019536:我 tensorflow/core/common_runtime/direct_session.cc:288]设备映射:

2018-08-07 18:44:59.019144: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Device mapping: no known devices. 2018-08-07 18:44:59.019536: I tensorflow/core/common_runtime/direct_session.cc:288] Device mapping:

MatMul:(MatMul):/job:localhost/副本:0/任务:0/设备:CPU:0 2018-08-07 18:44:59.019902:我 tensorflow/core/common_runtime/placer.cc:886] MatMul: (MatMul)/作业:本地主机/副本:0/任务:0/设备:CPU:0 a:(常量): /作业:localhost/副本:0/任务:0/设备:CPU:0 2018-08-07 18:44:59.019926:我tensorflow/core/common_runtime/placer.cc:886] a: (常量)/作业:本地主机/副本:0/任务:0/设备:CPU:0 b:(常量): /作业:localhost/副本:0/任务:0/设备:CPU:0 2018-08-07 18:44:59.019934:我tensorflow/core/common_runtime/placer.cc:886] b: (const)/job:localhost/replica:0/task:0/device:CPU:0 [[22. 28.] [ 49. 64.]]

MatMul: (MatMul): /job:localhost/replica:0/task:0/device:CPU:0 2018-08-07 18:44:59.019902: I tensorflow/core/common_runtime/placer.cc:886] MatMul: (MatMul)/job:localhost/replica:0/task:0/device:CPU:0 a: (Const): /job:localhost/replica:0/task:0/device:CPU:0 2018-08-07 18:44:59.019926: I tensorflow/core/common_runtime/placer.cc:886] a: (Const)/job:localhost/replica:0/task:0/device:CPU:0 b: (Const): /job:localhost/replica:0/task:0/device:CPU:0 2018-08-07 18:44:59.019934: I tensorflow/core/common_runtime/placer.cc:886] b: (Const)/job:localhost/replica:0/task:0/device:CPU:0 [[ 22. 28.] [ 49. 64.]]

如您所见,GPU没有进行任何计算. 当我更改代码以使用GPU的配置和处理比例时:

As you see there is no calculation done by GPU. and when I changed the code to use GPU's configuration and process fraction:

conf = tf.ConfigProto()
conf.gpu_options.per_process_gpu_memory_fraction = 0.4

with tf.Session(config = conf) as sess:
    x = sess.run(c)
print(x)

输出为

2018-08-07 18:52:22.681221:我 tensorflow/core/platform/cpu_feature_guard.cc:141]您的CPU支持 TensorFlow二进制文件未编译使用的指令:AVX2 FMA [[22. 28.] [49. 64.]]

2018-08-07 18:52:22.681221: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA [[ 22. 28.] [ 49. 64.]]

我该怎么做才能在GPU卡上运行会话?谢谢.

What can I do to run the session on GPU card? Thank you.

推荐答案

我相信TensorFlow-GPU仅支持NVIDIA CUDA计算能力> = 3.0 的GPU卡.

I believe TensorFlow-GPU only support GPU card with CUDA Compute Capability >= 3.0 of NVIDIA.

以下TensorFlow变体可用于安装:

The following TensorFlow variants are available for installation:

仅具有CPU支持的TensorFlow .如果您的系统没有NVIDIA®GPU,则必须安装此版本.通常,此版本的TensorFlow易于安装,因此,即使您具有NVIDIA GPU,我们也建议您先安装此版本.

TensorFlow with CPU support only. If your system does not have a NVIDIA® GPU, you must install this version. This version of TensorFlow is usually easier to install, so even if you have an NVIDIA GPU, we recommend installing this version first.

具有GPU支持的TensorFlow . TensorFlow程序通常在GPU而不是CPU上运行得更快.如果您运行对性能有要求的应用程序,并且系统具有满足先决条件的NVIDIA®GPU ,则应安装此版本.有关详细信息,请参见TensorFlow GPU支持.

TensorFlow with GPU support. TensorFlow programs usually run much faster on a GPU instead of a CPU. If you run performance-critical applications and your system has an NVIDIA® GPU that meets the prerequisites, you should install this version. See TensorFlow GPU support for details.

https://www.tensorflow.org/install/install_linux

这篇关于如何在AMD/ATI GPU上运行TensorFlow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆