Ingore `xla_gpu` which is specially reserved by TF
If building TF with XLA option enabled, an additional
`xla_gpu:0` device will be exposed to users which is a domain
for running graph in XLA mode. Should skip this device to
avoid the number of multi_gpu improperly inferred.
@@ -153,7 +153,7 @@ def multi_gpu_model(model, gpus=None, cpu_merge=True, cpu_relocation=False):
if not gpus:
# Using all visible GPUs when not specifying `gpus`
# e.g. CUDA_VISIBLE_DEVICES=0,2 python keras_mgpu.py
- gpus = len([x for x in available_devices if 'gpu' in x])
+ gpus = len([x for x in available_devices if '/gpu:' in x])
if isinstance(gpus, (list, tuple)):
if len(gpus) <= 1:
