【问题标题】:Choiche GPU tensorflow-directml or multi-gpuChoiche GPU tensorflow-directml 或 multi-gpu
【发布时间】:2021-08-04 11:39:29
【问题描述】:

我正在 Windows PC 上使用 tensorflow 训练模型,但训练量很低,因此我尝试将 tensorflow 配置为使用 GPU。 我安装了 tensorflow-directml(在带有 python 3.6 的 conda 环境中),因为我的 GPU 是 AMD Radeon GPU。 有了这个简单的代码

import tensorflow as tf
tf.test.is_gpu_available()

我收到此输出

2021-05-14 11:02:30.113880: 我 tensorflow/core/platform/cpu_feature_guard.cc:142] 你的 CPU 支持 此 TensorFlow 二进制文件未编译使用的指令:AVX2 2021-05-14 11:02:30.121580: 我 tensorflow/stream_executor/platform/default/dso_loader.cc:99] 成功打开动态库 C:\Users\v.rocca\anaconda3\envs\tfradeon\lib\site-packages\tensorflow_core\python/directml.adbd007a01a52364381a1c71ebb6fa1b2389c88d.dll 2021-05-14 11:02:30.765470: 我 tensorflow/core/common_runtime/dml/dml_device_cache.cc:249] DirectML 设备枚举:找到 2 个兼容的适配器。 2021-05-14 11:02:30.984834:我 tensorflow/core/common_runtime/dml/dml_device_cache.cc:185] DirectML: 在适配器 0 (Radeon (TM) 530) 上创建设备 2021-05-14 11:02:31.150992:我 tensorflow/stream_executor/platform/default/dso_loader.cc:99] 成功打开动态库Kernel32.dll 2021-05-14 11:02:31.174716:我 tensorflow/core/common_runtime/dml/dml_device_cache.cc:185] DirectML: 在适配器 1 (Intel(R) UHD Graphics 620) 上创建设备 True

所以 tensorflow 使用 Intel 集成 GPU 而不是 Radeon GPU。 如果我从管理硬件中禁用 Intel GPU,我会在输出中收到正确的 GPU

2021-05-14 10:47:09.171568: 我 tensorflow/core/platform/cpu_feature_guard.cc:142] 你的 CPU 支持 此 TensorFlow 二进制文件未编译使用的指令:AVX2 2021-05-14 10:47:09.176828: 我 tensorflow/stream_executor/platform/default/dso_loader.cc:99] 成功打开动态库 C:\Users\v.rocca\anaconda3\envs\tfradeon\lib\site-packages\tensorflow_core\python/directml.adbd007a01a52364381a1c71ebb6fa1b2389c88d.dll 2021-05-14 10:47:09.421265: 我 tensorflow/core/common_runtime/dml/dml_device_cache.cc:249] DirectML 设备枚举:找到 1 个兼容的适配器。 2021-05-14 10:47:09.626567:我 tensorflow/core/common_runtime/dml/dml_device_cache.cc:185] DirectML: 在适配器 0(Radeon (TM) 530)上创建设备

我不想每次都禁用英特尔 GPU,所以这是我的问题。 是否可以选择我要使用的 GPU?或者是否可以同时使用两个 GPU? 谢谢

【问题讨论】:

  • 不知道它是否适用于tensorflow-direcml,但我建议tf.config.set_visible_devices
  • 是的,set_visible_devices 在 tf.config.experimental 中,但是使用 tf.config.experimental.list_physical_devices() 我看不到我的物理 GPU,结果是 [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:DML:0', device_type='DML')]。我认为 GPU 是由 DML 设备抽象的,所以我无法通过 set_visible_device 中的 radeon GPU

标签: python tensorflow anaconda amd


【解决方案1】:

来自Microsoft

gpu_config = tf.GPUOptions()
gpu_config.visible_device_list = "1"

session = tf.Session(config=tf.ConfigProto(gpu_options=gpu_config))

【讨论】:

  • 使用此命令,gpu 似乎已更改,但输出给我此错误tensorflow.python.framework.errors_impl.AlreadyExistsError: TensorFlow device (DML:0) is being mapped to multiple DML devices (0 now, and 1 previously), which is not supported. This may be the result of providing different GPU configurations (ConfigProto.gpu_options, for example different visible_device_list) when creating multiple Sessions in the same process. This is not currently supported, see https://github.com/tensorflow/tensorflow/issues/19083
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-14
  • 2017-06-26
  • 1970-01-01
  • 2021-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多