From c9f86f6ea1714ce0a9d9f1c9d960e3f52688f8be Mon Sep 17 00:00:00 2001 From: Prithviraj Date: Sat, 4 Nov 2023 19:27:14 -0400 Subject: [PATCH 1/2] Fixing Multiple GPU example limited to one GPU Fixes #2563 Modifying data_parallel_tutorial.py, removed cuda:0 to enable using multiple GPUs. --- beginner_source/blitz/data_parallel_tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beginner_source/blitz/data_parallel_tutorial.py b/beginner_source/blitz/data_parallel_tutorial.py index eebca8ea52..aca9b3ad12 100644 --- a/beginner_source/blitz/data_parallel_tutorial.py +++ b/beginner_source/blitz/data_parallel_tutorial.py @@ -57,7 +57,7 @@ ###################################################################### # Device # -device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") +device = torch.device("cuda" if torch.cuda.is_available() else "cpu") ###################################################################### # Dummy DataSet From 2821752d7091367b8c01d63f99d8c90297dc2492 Mon Sep 17 00:00:00 2001 From: Prithviraj Date: Sun, 5 Nov 2023 13:59:01 -0500 Subject: [PATCH 2/2] Update data_parallel_tutorial.py to remove cuda:0 Removing cuda:0 from the comments --- beginner_source/blitz/data_parallel_tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beginner_source/blitz/data_parallel_tutorial.py b/beginner_source/blitz/data_parallel_tutorial.py index aca9b3ad12..2eb025ed49 100644 --- a/beginner_source/blitz/data_parallel_tutorial.py +++ b/beginner_source/blitz/data_parallel_tutorial.py @@ -9,7 +9,7 @@ .. code:: python - device = torch.device("cuda:0") + device = torch.device("cuda") model.to(device) Then, you can copy all your tensors to the GPU: