Tensorflow未在GPU上运行 [英] Tensorflow not running on GPU

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

问题描述

我已经准备好花费大量时间来研究堆栈溢出问题,并寻找答案,但找不到任何东西

I have aldready spent a considerable of time digging around on stack overflow and else looking for the answer, but couldn't find anything

大家好,

我在Tensorflow上运行Keras. 我90%确信我安装了Tensorflow GPU,有什么方法可以检查我做了哪些安装?

I am running Tensorflow with Keras on top. I am 90% sure I installed Tensorflow GPU, is there any way to check which install I did?

我试图从Jupyter笔记本上运行某些CNN模型,但我发现Keras在CPU上运行该模型(检查任务管理器,CPU为100%).

I was trying to do run some CNN models from Jupyter notebook and I noticed that Keras was running the model on the CPU (checked task manager, CPU was at 100%).

我尝试从tensorflow网站运行以下代码:

I tried running this code from the tensorflow website:

# Creates a graph.
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)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(c))

这就是我得到的:

MatMul: (MatMul): /job:localhost/replica:0/task:0/cpu:0
2017-06-29 17:09:38.783183: I c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] MatMul: (MatMul)/job:localhost/replica:0/task:0/cpu:0
b: (Const): /job:localhost/replica:0/task:0/cpu:0
2017-06-29 17:09:38.784779: I c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] b: (Const)/job:localhost/replica:0/task:0/cpu:0
a: (Const): /job:localhost/replica:0/task:0/cpu:0
2017-06-29 17:09:38.786128: I c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\common_runtime\simple_placer.cc:847] a: (Const)/job:localhost/replica:0/task:0/cpu:0
[[ 22.  28.]
 [ 49.  64.]]

对我来说,出于某种原因,我正在CPU上运行.

Which to me shows I am running on my CPU, for some reason.

我有一个GTX1050(驱动程序版本382.53),我安装了CUDA,Cudnn和tensorflow,没有任何问题.我还安装了Visual Studio 2015,因为它被列为兼容版本.

I have a GTX1050 (driver version 382.53), I installed CUDA, and Cudnn, and tensorflow installed without any problems. I installed Visual Studio 2015 as well since it was listed as a compatible version.

我记得CUDA提到了有关安装的不兼容驱动程序的信息,但是如果我没记错的话,CUDA应该已经安装了自己的驱动程序.

I remember CUDA mentioning something about an incompatible driver being installed, but if I recall correctly CUDA should have installed its own driver.

修改: 我运行了这些命令以列出可用的设备

I ran theses commands to list the available devices

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

这就是我得到的

[name: "/cpu:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 14922788031522107450
]

和很多这样的警告

2017-06-29 17:32:45.401429: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.

编辑2

尝试运行

pip3 install --upgrade tensorflow-gpu

我明白了

Requirement already up-to-date: tensorflow-gpu in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages
Requirement already up-to-date: markdown==2.2.0 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: html5lib==0.9999999 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: werkzeug>=0.11.10 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: wheel>=0.26 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: bleach==1.5.0 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: six>=1.10.0 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: protobuf>=3.2.0 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: backports.weakref==1.0rc1 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: numpy>=1.11.0 in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from tensorflow-gpu)
Requirement already up-to-date: setuptools in c:\users\xxx\appdata\local\programs\python\python35\lib\site-packages (from protobuf>=3.2.0->tensorflow-gpu)

已解决: 查看评论以获取解决方案. 感谢所有提供帮助的人!

Solved: Check comments for solution. Thanks to all who helped!

这是我的新手,因此非常感谢您的帮助! 谢谢.

I am new to this, so any help is greatly appreciated! Thank you.

推荐答案

要检查TensorFlow可以使用哪些设备,可以使用它并查看GPU卡是否可用:

To check which devices are available to TensorFlow you can use this and see if the GPU cards are available:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

编辑 另外,如果您使用TensorFlow Cuda版本,则应该看到这种日志:

Edit Also, you should see this kind of logs if you use TensorFlow Cuda version :

I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so.*.* locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so.*.*  locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so.*.*  locally

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

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