We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e67cb3 commit afcbcecCopy full SHA for afcbcec
tensordict/_td.py
@@ -268,8 +268,13 @@ def __init__(
268
sub_non_blocking = non_blocking
269
device = torch.device(device)
270
# Auto-index the device
271
- if device.type not in ("cpu", "meta") and device.index is None:
272
- device = torch.device(device.type, index=0)
+ if device.index is None:
+ if device.type == "cuda":
273
+ device = torch.device(
274
+ device.type, index=torch.cuda.current_device()
275
+ )
276
+ elif device.type not in ("cpu", "meta"):
277
+ device = torch.device(device.type, index=0)
278
if device.type == "cuda":
279
# CUDA does its sync by itself
280
call_sync = False
0 commit comments