Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行tensorflow gpu时发出警告。它使用GPU吗?_Tensorflow_Tensorflow Gpu - Fatal编程技术网

运行tensorflow gpu时发出警告。它使用GPU吗?

运行tensorflow gpu时发出警告。它使用GPU吗?,tensorflow,tensorflow-gpu,Tensorflow,Tensorflow Gpu,运行此命令时: sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) 我得到这个日志: 2017-06-16 11:29:42.305931: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are ava

运行此命令时:

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
我得到这个日志:

2017-06-16 11:29:42.305931: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 11:29:42.305950: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 11:29:42.305963: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 11:29:42.305975: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 11:29:42.305986: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-06-16 11:29:42.406689: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] 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-06-16 11:29:42.406961: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties: 
name: GeForce GTX 1070
major: 6 minor: 1 memoryClockRate (GHz) 1.7715
pciBusID 0000:01:00.0
Total memory: 7.92GiB
Free memory: 248.75MiB
2017-06-16 11:29:42.406991: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 
2017-06-16 11:29:42.407010: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0:   Y 
2017-06-16 11:29:42.407021: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0
2017-06-16 11:29:42.408087: I tensorflow/core/common_runtime/direct_session.cc:257] Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0
这能保证tensorflow代码将使用GPU吗?我有一个tensorflow的前一个版本,消息很清楚,它使用的是GPU。现在,在我升级它之后,消息是不同的,令人困惑的。 我可以看到它发现了我的GPU,但它是在使用它,还是仍然在使用CPU?如何从代码中检查以确保使用的设备是GPU

我很担心,因为我有:

import keras
Using TensorFlow backend

这表明keras使用的是CPU版本

使用设备范围如下:

with tf.device('/gpu:0'):
    a = tf.constant(0)
sess = tf.Session()
sess.run(a)
如果它没有抱怨无法将设备分配给节点,则表明您正在使用GPU


您可以更进一步,通过
log\u device\u placement

分析每个节点被分配到的位置。在发布此问题之前,您是否尝试过搜索?可能重复“是”我搜索过。这个问题并不完全是重复的。我会修改我的帖子,让它更清晰。谢谢。它似乎起作用了。给了我
创建TensorFlow设备(/gpu:0)->(设备:0,名称:GeForce GTX 1070,pci总线id:0000:01:00.0)
。应该没问题,对吧?您可以进一步添加日志\设备\位置,并查看操作的分配。最好的测试是矩阵乘法。速度上的差异会很大。好的,谢谢。但是仍然导入
keras
只提供使用TensorFlow后端的
(这意味着CPU)。如果它真的使用GPU,它应该提供更多的日志详细信息,说明它正在使用GPU:(我不确定Keras是如何工作的。尝试矩阵乘法并测量所花费的时间。我现在正在Keras上安装一个带有详细日志记录的模型,它非常快。当然这是一个GPU性能。感谢您的帮助。