Error database

The kernel appears to have died. It will restart automatically. (Jupyter)

The kernel process crashed hard — out of memory or a native-library failure — so no Python traceback exists. Run the same code as a script in a terminal to see the real error.

The message you saw
The kernel appears to have died. It will restart automatically. (Jupyter)

By Updated

The error

Output
The kernel appears to have died. It will restart automatically.

Google Colab's version of the same event:

Output
Your session crashed after using all available RAM.

What it means

The kernel — the Python process executing your cells — died abruptly, below the level where Python could catch anything. That is why there is no traceback: exceptions produce tracebacks, but this was a process kill or a native crash. Jupyter only notices its child vanished and restarts it. The message tells you nothing about the cause on purpose; the cause lives outside the notebook.

Why it happens

Two families cover most cases:

  • Out of memory. Loading a big dataset or model exceeded RAM; the OS killed the biggest process — the kernel. Most common by far, and Colab names it outright.
  • A native-code crash. A segfault or abort inside a C/C++/CUDA library: mismatched compiled packages (conda/pip mixes), the duplicate OpenMP runtime, a broken GPU driver call. The OMP case even prints its own message — in the terminal where Jupyter started, which nobody is watching.

How to fix it

1. Recover the real error message. Run the same code as a plain script in a terminal:

bash
python crash_repro.py

A memory kill shows Killed; a native crash prints the library's abort message or Segmentation fault. That message is the actual bug — continue on its page. On Linux, dmesg | grep -i "out of memory" confirms an OOM kill after the fact; the terminal that launched jupyter lab also holds kernel-side output worth scrolling.

2. If it is memory, shrink the working set. Load data in chunks, downcast dtypes, delete finished DataFrames (del df plus letting the cell finish), avoid keeping five copies of a dataset in the notebook's living variables. Notebooks accumulate state — restart and run only the needed cells to measure the true footprint. Model loading has its own fixes on the checkpoint-shards page.

3. If it is native, suspect the environment before the code. Fresh environment, single package source (all pip or all conda-forge), reinstall the compiled stack. The crash-on-a-specific-import pattern — kernel dies the moment a cell touches torch or numpy — is an environment problem in almost every instance.

4. On Colab, respond to what crashed it. RAM crash: smaller model, chunked data, or a higher-RAM runtime. GPU OOM shows differently (CUDA out of memory); disk-full shows differently again. The banner links a session log naming which.

5. Update the plumbing when crashes are random. Old ipykernel/jupyter versions have real crash bugs:

bash
pip install -U ipykernel jupyterlab

How to prevent it

Keep an eye on memory as you work — a resource monitor in the Jupyter UI, or df.memory_usage(deep=True).sum() after each big load. Treat the notebook as a view onto code that also runs as a script; anything long or heavy belongs in a script anyway, where crashes speak plainly.