Problem with submitting week1 assignment

I am getting the following error. Am I supposed to install the nvidia driver locally on my computer?

Cell #7. Can’t compile the student’s code. Error: AssertionError(‘\nFound no NVIDIA driver on your system. Please check that you\nhave an NVIDIA GPU and installed a driver from\nOfficial Drivers | NVIDIA’,)

Most likely that means you “hard-coded” the device to be “cuda” at some point in the code. The code in the notebook is written so that it can run on either the cpu or cuda, depending on the circumstances: when we run training, we need “cuda” to get the GPU for good performance. But when they run the grader, they want to use the cpu to save money. You just have to use the device value that they pass you and be careful never to assume you know a specific value for that parameter.

The other way to get that problem is to modify the line of code in this given code block that sets the device to ‘cuda’:

# Set your parameters
criterion = nn.BCEWithLogitsLoss()
n_epochs = 200
z_dim = 64
display_step = 500
batch_size = 128
lr = 0.00001
device = 'cuda'
# These break the grader:
# device='cuda'
# device = "cuda"

The problem is that the grader uses a simple “regular expression” to remove that line that sets the device and if you change it in the tiniest way, it causes a failure, even though the different code is perfectly correct python.

One thing that helped me is making the code device agnostic:

device = 'cuda' if torch.cuda.is_available() else 'cpu'

The addition does not violate the regex rule of the grader while ensuring that it can run even without CUDA.