C1W1 your first gan

I worked on the this assignment on my PC but it’s showing error could you hlep

Hi @Ashish_Sharma6.
This means part of your data is not on your main device. Are using device-agnostic code?

That means you are not managing the device parameter correctly. You must be hard-coding it instead of letting it be passed through. The point is that the grader needs to use the cpu device for cost, but we need to use cuda in the notebook for running the training to get it to run in reasonable time. They specifically parameterized the functions so that this can be controlled.

Also note that if you are running this on your local PC instead of the Coursera website there is not guarantee that things will “just work”. E.g. you may have different versions of the various packages that the notebooks use. These courses were published 3 or 4 years ago I think and things change rapidly in the python packages space in general.

so how should I procced from here can you guide

I don’t know about the device-agnostic code but I have downloaded the data on my device

Something like this:

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

And then while working, you’ll typically need to move the data to the device.

X, y = X.to(device), y.to(device)

and the model too


That’s device agnostic code. Carefully check your code to ensure you have this. Since, you’re doing this in your own environment setup. That will solve the error. All the data must be on the same device.
But a simpler way is to start afresh with only cpu. Then you use GPU when you arrange your code.

If you just want to do a quick test to see if you only have a problem because of running the code in the GPU, first I recommend testing it in the CPU.

We can’t help you if you are running the code locally. Do you have a GPU? Do you have your version of pytorch on your system configured with cuda support? I have no idea how to do that, but on any question like that the rule is “google is your friend”.

My question would be does your code work when you run it on the course website. If you have a problem there, I would recommend solving that first. That we can actually help you with.