'The kernel appears to have died. It will restart automatically' Error in my notebook

hey there, after running an assignment (online on Jupyter notebook) I’m getting the above message hence I’m unable to submit my assignment as the notebook doesn’t execute all the assignment tasks. Is there any way to get around this? thanks

Hello @hassan4! I hope you are doing well.

First, kindly upload your query to the relevant category. Currently, it is in a general category. Also, mentioned where you are getting this error, after running a training cell or any other cell. Perhaps your code has an infinite loop.


i am getting this error right now in course 4, week 4 (NST) in
content_target = vgg_model_outputs(content_image) # Content encoder
style_targets = vgg_model_outputs(style_image) # Style encoder

i cannot continue in my notebook because of that error

Well, I am not aware of this issue, but you can try restarting the kernel by clicking on “Kernel” in the menu bar and then selecting “Restart”.

If the issue persists, our expert mentors @paulinpaloalto @TMosh @rmwkwok will guide you.


sure enough i have tried that

Just to make sure we understand what you mean: did that solve the problem or not?

thanks for your reply also.
no, i have not solved the problem. i have even tried now to open a fresh notebook in order to rule out the possibility of a typo somewhere, but the error popped up again

They recently upgraded this notebook to use the GPU for better performance. What do you see if you add this cell right after the “import” cell:


I see this:


have you changed anything? for some reason it seems to work since minute or two

i also see 2.9.1 (don’t know what it was just before, when it did not work)

“We” didn’t change anything. There are typically no members of the course staff actually listening here. The mentors are just fellow students who have no ability to modify the assignments or the Coursera infrastructure.

But all this is running on the AWS cloud, so there can always be temporary “bad weather” which appears for no apparent reason and then disappears similarly.

Ah ok, i understand, haha.
Seems to have been one of those ‘bad weather’ incidents then. thanks a lot for your help anyway! :slight_smile:

Thanks ‘bad weather’ is gone :smile: :smiley:

The whole ecosystem here is incredibly complicated, so there are lots of potential “points of failure” between your browser and AWS. Some firewall on you local area network can get reconfigured or some router at your ISP hiccups or come backhoe someplace accidentally excavates a cable and yadda yadda yadda.

The key thing to understand about how the notebooks work is that the UI runs in your browser (of course), but anytime you click “Run” it is sending a command over an SSL connection to a Docker image running in the AWS cloud and all the actual “execution” or anything to do with what they call the “kernel” is actually executing in a linux VM on AWS. I haven’t personally developed any complex server apps, but have worked in companies where that was done and have had just enough discussions with the folks working on the server side stuff to realize that a system the scale of AWS is incredibly complicated. It’s kind of amazing that any of this stuff works as well as it does.

hey @saifkhanengr sorry I tried posting it under the GANs specialization I’m currently working on but couldn’t (please suggest where to post this). This kernel issue occurs when I’m training my model so the last cell of the assignment task. @paulinpaloalto

There are other ways to hit problems like this because of the way your code works. The training in a lot of the GANs notebooks takes quite a few iterations and can cause the memory image of the notebook to get quite large. You have to be careful not to make that problem worse by including any print statements in “inner” loops that expand the output even more.

Try doing “Kernel → Restart and Clear Output” followed by “Save” and then you should be able to submit to the grader. Of course you lose the output of your training when you do that, but that’s part of the point, right?

worked fine, thanks! I thought the output had to be there as well for a submission

1 Like

Ah, that’s a good point: they don’t really mention that anywhere, but the grader only cares about your code, not the output. It runs your functions with its own test cases. Having a large memory image slows the grader down and can even cause it to fail in extreme cases.

Hi - I have a similar problem. Running the GAN C3W2A notebook, I get through all the assignment code cells. On the final Train cell, I get “The kernel appears to have died. It will restart automatically.” Upper right shows RED “Dead Kernel.”. It does not restart.

This has happened 1/2 dozen times even after exiting, refreshing, re-opening the notebook fresh, etc. The grader accepted the assignment. However, after working all the pieces leading up to the train step, I can’t see the results! I want to tweak parameters, etc. & see how it changes the results. Is there a way to troubleshoot why the kernel keeps dying? Thanks!