python - 我怎么知道 tensorflow 是否使用 cuda 和 cudnn?

标签 python tensorflow

我使用的是 Ubuntu 16.04。这是 tensorflow 信息:

>>> pip show tensorflow-gpu
pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.2.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /home/xxxx/anaconda3/envs/tensorflow/lib/python3.5/site-packages
Requires: markdown, backports.weakref, wheel, bleach, html5lib, protobuf, numpy, six, werkzeug

cuda 信息:

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

当我从 Ubuntu 终端在 Python 中导入 tensorflow 时,我没有得到如下加载信息。

>>> import tensorflow
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
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally

如果我在终端中运行 python 程序,我会得到不同的信息。

2017-06-20 16:08:18.075709: 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-20 16:08:18.075733: 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-20 16:08:18.075740: 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-20 16:08:18.075744: 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-20 16:08:18.075750: 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-20 16:08:18.260629: 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-06-20 16:08:18.261462: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: 
name: Quadro K620M
major: 5 minor: 0 memoryClockRate (GHz) 1.124
pciBusID 0000:08:00.0
Total memory: 1.96GiB
Free memory: 1.58GiB
2017-06-20 16:08:18.261514: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 
2017-06-20 16:08:18.261524: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y 
2017-06-20 16:08:18.261550: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Quadro K620M, pci bus id: 0000:08:00.0)
2

我如何知道 tensorflow 是否正在使用 cuda 和 cudnn?我还需要提供哪些其他信息?

最佳答案

您可以通过 nvidia-smi 检查 GPU 是否被 python/tensorflow 进程使用。如果没有使用 GPU 的进程,tensorflow 不会使用 cuda 和 cudnn。

关于python - 我怎么知道 tensorflow 是否使用 cuda 和 cudnn?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44663485/

相关文章:

python - 如何从嵌套列表中提取特定项目并附加到新列?

python - 在 Python 中打开一个文本文件

tensorflow - .tflite模型每次初始化相同的检测框

TensorFlow 中的 Azure CustomVision 认知服务导出模型缺少文件

python - 具有随机权重的神经网络无法学习

python - 并行迭代 pandas df

python - 插入似乎没有发生

python - 是否有可能有两个 float 未通过 lt、gt 和 eq 测试

python - 使用 Tensorflow C++ API 执行在 skflow 中训练的模型

python - 属性错误: module 'tensorflow' has no attribute 'batch_matrix_band_part'