当我运行keras脚本时,我得到以下输出:
Using TensorFlow backend.
2017-06-14 17:40:44.621761: 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-14 17:40:44.621783: 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-14 17:40:44.621788: 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-14 17:40:44.621791: 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-14 17:40:44.621795: 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-14 17:40:44.721911: 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-14 17:40:44.722288: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0
with properties:
name: GeForce GTX 850M
major: 5 minor: 0 memoryClockRate (GHz) 0.9015
pciBusID 0000:0a:00.0
Total memory: 3.95GiB
Free memory: 3.69GiB
2017-06-14 17:40:44.722302: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-06-14 17:40:44.722307: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-06-14 17:40:44.722312: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating
TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 850M,
pci bus id: 0000:0a:00.0)
这是什么意思?我是否使用GPU或CPU版本的tenstorflow?
在安装keras之前,我使用的是tensorflow的GPU版本。
另外sudopip3列表
显示了tensorflowgpu(1.1.0)
,与tensorflowcpu
完全不同。
运行[this stackoverflow question]中提到的命令,可以得到以下结果:
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-14 17:53:31.424793: 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-14 17:53:31.424803: 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-14 17:53:31.424812: 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-14 17:53:31.424820: 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-14 17:53:31.540959: 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-14 17:53:31.541359: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0
with properties:
name: GeForce GTX 850M
major: 5 minor: 0 memoryClockRate (GHz) 0.9015
pciBusID 0000:0a:00.0
Total memory: 3.95GiB
Free memory: 128.12MiB
2017-06-14 17:53:31.541407: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0
2017-06-14 17:53:31.541420: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y
2017-06-14 17:53:31.541441: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating
TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 850M,
pci bus id: 0000:0a:00.0)
2017-06-14 17:53:31.547902: E
tensorflow/stream_executor/cuda/cuda_driver.cc:893] failed to
allocate 128.12M (134348800 bytes) from device:
CUDA_ERROR_OUT_OF_MEMORY
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce
GTX 850M, pci bus id: 0000:0a:00.0
2017-06-14 17:53:31.549482: I
tensorflow/core/common_runtime/direct_session.cc:257] Device
mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce
GTX 850M, pci bus id: 0000:0a:00.0
要找出您的操作和张量分配给了哪些设备,请创建会话,并将log_device_placement configuration选项设置为True。
# 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))
您应该看到以下输出:
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K40c, pci bus
id: 0000:05:00.0
b: /job:localhost/replica:0/task:0/device:GPU:0
a: /job:localhost/replica:0/task:0/device:GPU:0
MatMul: /job:localhost/replica:0/task:0/device:GPU:0
[[ 22. 28.]
[ 49. 64.]]
有关更多详细信息,请参阅使用带有tensorflow的GPU的链接
为了让Keras使用GPU,许多事情都必须顺利进行。把这个放在你木星笔记本的顶部:
# confirm TensorFlow sees the GPU
from tensorflow.python.client import device_lib
assert 'GPU' in str(device_lib.list_local_devices())
# confirm Keras sees the GPU (for TensorFlow 1.X + Keras)
from keras import backend
assert len(backend.tensorflow_backend._get_available_gpus()) > 0
# confirm PyTorch sees the GPU
from torch import cuda
assert cuda.is_available()
assert cuda.device_count() > 0
print(cuda.get_device_name(cuda.current_device()))
注意:随着TensorFlow 2.0的发布,Keras现在作为TF API的一部分包含在内。
您正在使用GPU版本。您可以列出可用的tensorflow设备(同时检查此问题):
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices()) # list of DeviceAttributes
编辑:
带张量流
import tensorflow as tf
tf.test.is_gpu_available() # True/False
# Or only check for gpu's with cuda support
tf.test.is_gpu_available(cuda_only=True)
编辑2:
上述函数在tensorflow中被弃用
import tensorflow as tf
tf.config.list_physical_devices('GPU')
注:
在您的情况下,cpu和gpu都可用,如果您使用tensorflow的cpu版本,gpu将不会列出。在您的情况下,无需设置tensorflow设备()和tf.device(“…”)
),tensorflow将自动选择您的gpu!
此外,您的
sudopip3列表
清楚地显示您正在使用tensorflow gpu。如果您使用的是tensoflow cpu版本,那么名称将类似于tensorflow(1.1.0)
。
有关警告的信息,请检查此问题。
问题内容: 运行keras脚本时,得到以下输出: 这是什么意思?我是否正在使用GPU或CPU版本的Tensorflow? 在安装keras之前,我正在使用Tensorflow的GPU版本。 还显示和没有什么像。 运行[此stackoverflow问题]中提到的命令,将得到以下信息: 问题答案: 您正在使用GPU版本。您可以列出可用的tensorflow设备(也请检查此问题): 编辑: 使用tens
我知道在安装tensorflow时,您可以安装GPU或CPU版本。如何检查安装了哪一个(我使用linux)。 如果安装了GPU版本,如果GPU不可用,它会自动在CPU上运行吗?如果GPU可用,是否需要设置特定的字段或值来确保它在GPU上运行?
与此问题相同,但适用于caffe。我想要一个命令,我可以把我的python脚本,以检查是否使用gpu。 当我的模型运行时,我检查了nvidia smi,我看到python被认为是一个进程,但使用情况不适用。 我还试着经营咖啡馆。设置_mode_cpu()命令时,考虑到时间会非常不同,但有命令的时间和没有命令的时间相同。
问题内容: 我想知道是否正在使用我的GPU。在此过程中,可以检测是否有来自GPU的任何活动,但是我想要在脚本中编写一些东西。 有办法吗? 问题答案: 这将起作用: 这告诉我GPU正在被使用。
我想知道Pytork是否正在使用我的GPU。使用可以检测在这个过程中是否有来自GPU的任何活动,但是我想要用脚本编写一些东西。 有没有办法做到这一点?
我们正在尝试使用windows中的ServerSpec来验证应用程序安装。我在ruby文件中写了下面几行(用Test.rb) 我这样运行脚本。 它正在检查是否正确。但是我想检查msi(windows installer软件包)的特定版本。如何在serverspec中做到这一点?