Skip to content

Commit

Permalink
fix: handle multiple GPUs in paddle backend to_device
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudAshraf97 committed Oct 25, 2023
1 parent 7e9e762 commit 40b27d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ivy/functional/backends/paddle/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def to_device(
device = as_native_dev(device)
if device.is_cpu_place() and not x.place.is_cpu_place():
return x.cpu()
elif device.is_gpu_place() and not x.place.is_gpu_place():
elif (device.is_gpu_place() and not x.place.is_gpu_place()) or (
x.place.is_gpu_place()
and device.is_gpu_place()
and x.gpu_device_id() != device.gpu_device_id()
):
return x.cuda(device.gpu_device_id())
else:
return x
Expand Down

0 comments on commit 40b27d8

Please sign in to comment.