【问题标题】:TensorFlow not running on GPU(keras with TF backend)TensorFlow 未在 GPU 上运行(带有 TF 后端的 keras)
【发布时间】:2018-09-26 20:47:34
【问题描述】:

我已按照installing tensorflow with GPU support 上的步骤操作,并确保我使用的机器具有兼容的 GPU,但 TensorFlow 似乎仍然无法在我的机器上正常运行。我有一个程序使用 TensorFlow 后端在大量数据上训练 keras 顺序模型(使用 python 2.7),训练时的输出如下:

2018-04-17 00:35:13.837040: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-04-17 00:35:14.042784: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-04-17 00:35:14.043143: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: 
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:00:1e.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
2018-04-17 00:35:14.043186: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1423] Adding visible gpu devices: 0
2018-04-17 00:35:16.374355: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-04-17 00:35:16.374397: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917]      0 
2018-04-17 00:35:16.374405: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0:   N 
2018-04-17 00:35:16.380956: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10764 MB memory) -> physical GPU (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0, compute capability: 3.7)

我真的不明白这些日志的含义,但是,我在只有一个 CPU 的设备上同时运行这项作业,并且完成训练作业所花费的时间是相同的。谁能帮我告诉我如何让我的训练工作在 GPU 上运行?提前致谢!

【问题讨论】:

    标签: python tensorflow machine-learning keras gpu


    【解决方案1】:

    您可能会考虑尝试指定一个 GPU 来运行您的程序,这是一段简单的代码。

    with tf.device('/gpu:1'):
      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)
    sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
    print sess.run(c)
    

    如果没有,我推荐使用anaconda3创建TensorFlow-GPU虚拟环境,一般默认GPU版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      • 2017-12-23
      • 2020-08-11
      • 2018-07-18
      • 2017-12-03
      • 2016-12-19
      相关资源
      最近更新 更多