Code

Indexing Multiple GPUs in PyTorch

When multiple GPUs are available in PyTorch, the ithi^{\textrm{th}} GPU is represented using torch.device(f'cuda:{i}'), where the index ii starts at 0. The notations cuda:0 and cuda are equivalent and both refer to the first GPU.

0

1

Updated 2026-07-03

Tags

D2L

Dive into Deep Learning @ D2L