【问题标题】:Unable to use GPU to Fit Model using Keras无法使用 GPU 来拟合使用 Keras 的模型
【发布时间】:2020-12-02 20:39:34
【问题描述】:

我有一个 Windows 10 操作系统,我在 Jupyter Notebook 上使用 Tensorflow gpu 版本。

conda 4.9.2

python 3.7

tf '2.3.1'

cudatoolkit 11.0.221

tf.config.experimental.list_physical_devices()

返回:

[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
PhysicalDevice(name='/physical_device:XLA_CPU:0', device_type='XLA_CPU'),
PhysicalDevice(name='/physical_device:XLA_GPU:0', device_type='XLA_GPU')]

和,

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

返回:

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 10428669251348137268
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 2248949917928228630
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 17815507612308274706
physical_device_desc: "device: XLA_GPU device"
]

但是,当我想拟合模型时,它开始使用 100% 的 CPU 而不是 GPU。

以前有人遇到过这个问题吗?

【问题讨论】:

  • 你需要 cudatoolkit 10.1.243 和 cudnn 7.6.5

标签: python tensorflow keras


【解决方案1】:

最简单的方法是卸载 tensorflow。如果你安装了 anaconda 使用 conda 安装 tensflow。它将安装 tensorflow 2.1.1、cudatoolkit 10.1.243 和 cudnn 7.65。这些与 tensorflow 2.31 兼容。然后使用 pip 安装 tensorflow 2.3.1。 Conda for windows 只能安装 tensorflow 到 version2.1。

【讨论】:

    猜你喜欢
    • 2022-01-10
    • 1970-01-01
    • 2019-01-13
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 2020-08-19
    • 2020-08-25
    • 2021-08-30
    相关资源
    最近更新 更多