From 9116086062fb60afd8128effefcc8b595a754892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2EYasoob=20Ullah=20Khalid=20=E2=98=BA?= Date: Thu, 18 Jun 2026 13:58:34 -0700 Subject: [PATCH] Move image and labels to GPU The current solution misses this and that results in an exception as the model is in the GPU but the model inputs are on the CPU. --- lab2/solutions/PT_Part1_MNIST_Solution.ipynb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lab2/solutions/PT_Part1_MNIST_Solution.ipynb b/lab2/solutions/PT_Part1_MNIST_Solution.ipynb index efb23831..c1423d96 100644 --- a/lab2/solutions/PT_Part1_MNIST_Solution.ipynb +++ b/lab2/solutions/PT_Part1_MNIST_Solution.ipynb @@ -915,6 +915,9 @@ "# Process test set in batches\n", "with torch.no_grad():\n", " for images, labels in testset_loader:\n", + " # TODO: ensure evalaution happens on the GPU\n", + " images, labels = images.to(device), labels.to(device)\n", + "\n", " outputs = cnn_model(images)\n", "\n", " # Apply softmax to get probabilities from the predicted logits\n",