有没有办法将我所有的 GPU 设置为不是 XLA,这样我就可以用多个 GPU 而不是一个 GPU 进行训练?



我想使用多个GPU训练keras模型。我的理解是,您目前无法使用XLA训练多个GPU。问题是我不知道如何关闭XLA。每个 GPU 都列为 xla GPU。

作为参考,我在最新的 Ubuntu 桌面上使用 3 个 RTX2070。 Nvidia-SMI确实显示了所有3个GPU。

我尝试卸载并重新安装tensorflow-gpu.这无济于事。

keras.utils.training_utils import multi_gpu_model
model = multi_gpu_model(model,gpus=3)

值错误:

To call `multi_gpu_model` with `gpus=3`, we expect the following devices to be available: ['/cpu:0', '/gpu:0', '/gpu:1', '/gpu:2']. However this machine only has: ['/cpu:0', '/xla_cpu:0', '/xla_gpu:0', '/xla_gpu:1', '/xla_gpu:2']. Try reducing `gpus`.

编辑:我正在使用tensorflow-gpu,实际上我刚刚确认它甚至没有使用一个gpu。我通过将批量大小增加到 10,000 来确认这一点,并且没有看到 nvidia-smi 的变化,但我确实通过 htop 看到了 cpu/内存使用情况的变化。

编辑2:

tf.test.gpu_device_name()

仅打印一个空字符串

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
prints all of my devices...
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 7781250607362587360
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 12317810384332135154
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 1761593194774305176
physical_device_desc: "device: XLA_GPU device"
, name: "/device:XLA_GPU:1"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 11323027499711415341
physical_device_desc: "device: XLA_GPU device"
, name: "/device:XLA_GPU:2"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 3573490477127930095
physical_device_desc: "device: XLA_GPU device"
]

我也遇到了这个问题。

有时我通过重新安装 tensorflow-gpu 包来修复它。

pip uninstall tensorflow-gpu
pip install tensorflow-gpu

但是,有时这些命令不起作用。所以我尝试了以下方法,效果令人惊讶。

conda install -c anaconda tensorflow-gpu

相关内容

最新更新