使用GPU进行Tensorflow,检测到右GPU但不使用它进行计算

时间:2017-06-02 13:35:09

标签: python tensorflow nvidia cudnn

所以我在我的笔记本电脑上安装了Tensorflow for Python 3.5,这是一台托管Nvidia Geforce Pascal GPU的Windows机器。我还安装了CUDA并下载了cuDNN并将其添加到PATH变量中。我的tensorflow代码确实编译,但如果我监视我的GPU,我可以看到,它不会计算任何东西,而是我的CPU正在完成整个工作。我还在控制台中得到一个输出,确认已检测到GPU:

2017-06-02 15:22:22.140283: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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. 2017-06-02 15:22:22.140600: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-02 15:22:22.140899: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-02 15:22:22.141108: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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-02 15:22:22.141321: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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-02 15:22:22.141582: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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-02 15:22:22.141803: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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-02 15:22:22.142130: W c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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-02 15:22:22.561687: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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.645 pciBusID 0000:01:00.0 Total memory: 8.00GiB Free memory: 6.65GiB 2017-06-02 15:22:22.561949: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:908] DMA: 0 2017-06-02 15:22:22.562073: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\common_runtime\gpu\gpu_device.cc:918] 0: Y 2017-06-02 15:22:22.562435: I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\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)

有人可以向我解释一下吗?

编辑:好的,似乎,我没有看到使用准确的用法。 GPU实际上是使用的,但仅限于小峰值。大部分工作仍由CPU完成。我正在运行一个有3个卷积和2个完全连接层的CNN。但这不是正确的吗?![GPU Usage] 1

1 个答案:

答案 0 :(得分:1)

为了提高效果,我建议您查看tensorflow performance guide

特别是我通过使用命令with tf.device('/cpu:0'):

在cpu端定位预处理来尝试合理的加速

请注意,加速因子与架构有关,如article

所述