Dead kernel jupiter notebook что это
Перейти к содержимому

Dead kernel jupiter notebook что это

  • автор:

Kernel Died error post installing tensorflow

You’re now watching this thread. If you’ve opted in to email or web notifications, you’ll be notified when there’s activity. Click again to stop watching or visit your profile to manage watched threads and notifications.

You’ve stopped watching this thread and will no longer receive emails or web notifications when there’s activity. Click again to start watching.

I m using macbook air 13″ and pursuing Artificial Intelligence course

I m facing huge problem with Jupyter notebook post installing tensorflow as the kernel keeps dying and I have literally tried solution in every article/resource on Google

Nothing seems to be fixing the issue.

It began only when I started to run code for Convolutional Neural Network

Please help me fix this issue and understand why its not getting fixed

At the moment, I can only think of trading Macbook for Windows Laptop but It will be very hard as I have not had hands-on Windows laptop

Hope to hear back soon

Thanks Keshav Lal Seth

Copy to clipboard
Share this post
Copied to Clipboard

I am facing the same issue today. After uninstalling anaconda python and reinstalling it, I realize that the issue occurs simply because I used «pip install tensor flow». Each time after I did this, my Jupyter notebook kernel would not work. The laptop I use is MacBook Pro 2021.

I’m using the M2. and the same thing happens.

Replies

Can you provide a bit more information on the problem you are facing: Which OS version and version of the MacBook Air (Intel or M1) are you running on? Which versions of the Jupyter packages and Tensorflow packages are you using? Did you follow the instructions at https://developer.apple.com/metal/tensorflow-plugin/ when installing? Can you provide an example script that causes the crash for you so we can try to reproduce this issue?

Frameworks Engineer
Copy to clipboard
Share this post
Copied to Clipboard

Thanks for your response!

—Which OS version and version of the MacBook Air (Intel or M1) are you running on?

MacBook Air — 13″ (M1)

—Which versions of the Jupyter packages and Tensorflow packages are you using?

I’ve downloaded Anaconda from link available online https://www.anaconda.com/products/individual It has Jupyter 6.4.5 in it.

It was working fine until Deep — ANN. The moment I started coding for CNN it returned error kernel died. I did not change anything. So it quite strange what happened. Hopeful of getting it fixed thrpugh this thread 🙂

Same for Tensorflow as well https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/

—Did you follow the instructions at https://developer.apple.com/metal/tensorflow-plugin/%C2%A0when installing?

No, sorry. I wasn’t familiar with this resource. I m not able to follow this resource. could you explain & if this is necessary after having above steps doen and they been working fine earlier

—Can you provide an example script that causes the crash for you so we can try to reproduce this issue?

import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import seaborn as sb #import os #os.environ[«CUDA_DEVICE_ORDER»]=»PCI_BUS_ID» #os.environ[«CUDA_VISIBLE_DEVICES»]=»0″

from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Conv2D,MaxPooling2D,Flatten,Dense

from tensorflow.keras.preprocessing import image

Layer (type) Output Shape Param #

conv2d (Conv2D) (None, 126, 126, 16) 448

max_pooling2d (MaxPooling2D (None, 63, 63, 16) 0
)

conv2d_1 (Conv2D) (None, 61, 61, 32) 4640

max_pooling2d_1 (MaxPooling (None, 30, 30, 32) 0
2D)

flatten (Flatten) (None, 28800) 0

dense (Dense) (None, 128) 3686528

dense_1 (Dense) (None, 5) 645

Make the data ready

from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_datagen=ImageDataGenerator(rescale=1/255., rotation_range=45, width_shift_range=0.2, height_shift_range=0.2, shear_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode=’reflect’)

train_set=train_datagen.flow_from_directory(‘C:\Users\tksen\Desktop\DL\Datasets\flower_photos\Training’, target_size=(128,128), batch_size=128, class_mode=’categorical’)

test_set=test_datagen.flow_from_directory(‘C:\Users\tksen\Desktop\DL\Datasets\flower_photos\Testing’, target_size=(128,128), batch_size=128, class_mode=’categorical’)

flower_classifier.fit(train_set, steps_per_epoch=2736//128, epochs=5, validation_data=test_set, validation_steps=934//128)

Testing the model with single image

print(‘The test image class is :’,ypred.argmax())

class_name=train_set.class_indices pos=np.array(list(class_name.values()))==ypred.argmax() name=np.array(list(class_name.keys())) print(‘The Predicted class name is:’) print(name[pos][0]) test_img

Please let me know if I can give you any other details

Copy to clipboard
Share this post
Copied to Clipboard

Yes it is indeed important to take the steps outlined in the tensorflow-plugin guide when setting up the Python environment in order to ensure the compatibility among different python packages on the M1 machine. There are multiple reasons why the Jupyter kernel can die and among one of them could be some unexpected conflict between the various packages. This setup is also the one we are testing and supporting, allowing us to debug the issues in case any problems arise.

Additionally the instructions on TensorFlow installation in the Anaconda site would not allow you to take advantage of the GPU on the M1 Mac since the computations are passed to the GPU using the TensorFlows pluggable device architecture which requires a base TensorFlow version (tensorflow_macos package) as well as the GPU plugin (tensorflow_metal package) to run.

So please try following the instructions for arm64 on the installation page https://developer.apple.com/metal/tensorflow-plugin/ to set up the virtual environment for Python and installing the packages and let me know if there is a specific step that is not working on your machine. Also note that you need to make sure your operating system is updated to match the requirements (macOS 12.0+).

Frameworks Engineer
Copy to clipboard
Share this post
Copied to Clipboard

Ok any thoughts and comments on rest of the steps mentions that I have folowed Also, where and how below mentioned to use these and other commands conda terminal post opening jupyter notebook? Download and install Conda env: chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh sh ~/Downloads/Miniforge3-MacOSX-arm64.sh source ~/miniforge3/bin/activate

Ok any thoughts and comments on rest of the steps mentions that I have followed

Also, where and how below mentioned to use these and other commands conda terminal post opening jupyter notebook?

Download and install Conda env: chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh sh ~/Downloads/Miniforge3-MacOSX-arm64.sh source ~/miniforge3/bin/activate

Copy to clipboard
Share this post
Copied to Clipboard

Notice that the step of setting up the environment is done before you open the notebook. After the setup is complete you will open the notebook within this environment so that the notebook is able to use the packages available in the environment. After having installed and activated the conda environment with the commands you wrote above following the Tensorflow Plugin guide, your terminal should show something like (base) tag at the beginning of the command line row to indicate you are in the conda base environment. You can continue on the command line for the remaining steps of installing the TensorFlow-dependencies with conda install -c apple tensorflow-deps , the TensorFlow base python -m pip install tensorflow-macos and the TensorFlow metal plugin python -m pip install tensorflow-metal . Now you can install the Jupyter notebook to the environment using conda install notebook . You can also install any other python packages you might need in your notebook directly to the environment on the command line. After this you can call the usual jupyter notebook on the command line to start the notebook server and start working on your notebook within the conda environment you have just set up with the latest TensorFlow for MacOS.

Frameworks Engineer

The steps share in https://developer.apple.com/metal/tensorflow-plugin/ are nicely explained but it returns error when trying to load via terminal

My course is getting affected big time as Google colab is not the right alternate and Jupyter has to work on my system

Some commands dont work on colab pls help me get this fixed

(base) keshavlalseth@ Keshavs -MacBook-Air ~ % conda install -c apple tensorflow-deps Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

— https://conda.anaconda.org/apple/osx-64 — https://conda.anaconda.org/apple/noarch — https://repo.anaconda.com/pkgs/main/osx-64 — https://repo.anaconda.com/pkgs/main/noarch — https://repo.anaconda.com/pkgs/r/osx-64 — https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you’re looking for, navigate to

and use the search bar at the top of the page.

(base) keshavlalseth@ Keshavs -MacBook-Air ~ % python -m pip install tensorflow-macos

Collecting tensorflow-macos ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos (base) keshavlalseth@ Keshavs -MacBook-Air ~ % python -m pip install tensorflow-metal

Collecting tensorflow-metal ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none) ERROR: No matching distribution found for tensorflow-metal

(base) keshavlalseth@ Keshavs -MacBook-Air ~ % conda install -c apple tensorflow-deps==2.5.0

Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

— https://conda.anaconda.org/apple/osx-64 — https://conda.anaconda.org/apple/noarch — https://repo.anaconda.com/pkgs/main/osx-64 — https://repo.anaconda.com/pkgs/main/noarch — https://repo.anaconda.com/pkgs/r/osx-64 — https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you’re looking for, navigate to

and use the search bar at the top of the page.

These steps in apple’s help article dont help at all

Jupyter notebook — Dead Kernel

I am trying to work with jupyter notebook, but when I open a file I receive the following error: The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened. In the CMD I see the following:

(base) C:\Users\Dan Eran>jupyter notebook [W 19:05:33.006 NotebookApp] Error loading server extension jupyterlab Traceback (most recent call last): File "C:\Users\Dan Eran\AppData\Roaming\Python\Python36\site-packages\notebook\notebookapp.py", line 1451, in init_server_extensions mod = importlib.import_module(modulename) File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'jupyterlab' [I 19:05:33.122 NotebookApp] Serving notebooks from local directory: C:\Users\Dan Eran [I 19:05:33.122 NotebookApp] 0 active kernels [I 19:05:33.122 NotebookApp] The Jupyter Notebook is running at: [I 19:05:33.122 NotebookApp] http://localhost:8888/?token=99a355c23c6617857e387f53d0af607ae26b89c20598336e [I 19:05:33.122 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 19:05:33.122 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8888/?token=99a355c23c6617857e387f53d0af607ae26b89c20598336e [I 19:05:33.247 NotebookApp] Accepting one-time-token-authenticated connection from ::1 [I 19:05:42.699 NotebookApp] Creating new notebook in [I 19:05:43.563 NotebookApp] Kernel started: 1433cbbf-f4b9-4dd3-be19-e91d7ee3d82f Traceback (most recent call last): File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in from .connect import * File "C:\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in from IPython.core.profiledir import ProfileDir ModuleNotFoundError: No module named 'IPython' [I 19:05:46.555 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports Traceback (most recent call last): File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in from .connect import * File "C:\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in from IPython.core.profiledir import ProfileDir ModuleNotFoundError: No module named 'IPython' [I 19:05:49.591 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports Traceback (most recent call last): File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in from .connect import * File "C:\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in from IPython.core.profiledir import ProfileDir ModuleNotFoundError: No module named 'IPython' [I 19:05:52.620 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports Traceback (most recent call last): File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in from .connect import * File "C:\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in from IPython.core.profiledir import ProfileDir ModuleNotFoundError: No module named 'IPython' [W 19:05:53.595 NotebookApp] Timeout waiting for kernel_info reply from 1433cbbf-f4b9-4dd3-be19-e91d7ee3d82f [I 19:05:55.632 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports WARNING:root:kernel 1433cbbf-f4b9-4dd3-be19-e91d7ee3d82f restarted Traceback (most recent call last): File "C:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Anaconda3\lib\site-packages\ipykernel\__init__.py", line 2, in from .connect import * File "C:\Anaconda3\lib\site-packages\ipykernel\connect.py", line 13, in from IPython.core.profiledir import ProfileDir ModuleNotFoundError: No module named 'IPython' [W 19:05:58.671 NotebookApp] KernelRestarter: restart failed [W 19:05:58.671 NotebookApp] Kernel 1433cbbf-f4b9-4dd3-be19-e91d7ee3d82f died, removing from map. ERROR:root:kernel 1433cbbf-f4b9-4dd3-be19-e91d7ee3d82f restarted failed! [W 19:05:58.705 NotebookApp] 410 DELETE /api/sessions/fd456273-adb3-48cd-92f8-d531c9b8f7a8 (::1): Kernel deleted before session [W 19:05:58.709 NotebookApp] Kernel deleted before session [W 19:05:58.709 NotebookApp] 410 DELETE /api/sessions/fd456273-adb3-48cd-92f8-d531c9b8f7a8 (::1) 4.00ms referer=http://localhost:8888/notebooks/Untitled11.ipynb?kernel_name=python3 

I have tried to uninstall and then reinstall some modules. However, I was not able to solve the problem. any ideas? THANKS!!

Forums

Hello, I have created my first Jupyter Notebook but it keeps displaying the message below along with the error log. I cancelled all running consoles, which had no affect. Can you advise what the problem is? Many thanks.

Dead kernel

The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened. 
Traceback (most recent call last): File "/usr/lib/python3.4/site-packages/notebook/base/handlers.py", line 457, in wrapper result = yield gen.maybe_future(method(self, *args, **kwargs)) File "/usr/lib/python3.4/site-packages/tornado/gen.py", line 1055, in run value = future.result() File "/usr/lib/python3.4/site-packages/tornado/concurrent.py", line 238, in result raise_exc_info(self._exc_info) File "", line 4, in raise_exc_info File "/usr/lib/python3.4/site-packages/tornado/gen.py", line 1069, in run yielded = self.gen.send(value) File "/usr/lib/python3.4/site-packages/notebook/services/sessions/handlers.py", line 57, in post model = yield gen.maybe_future(sm.get_session(path=path)) File "/usr/lib/python3.4/site-packages/notebook/services/sessions/sessionmanager.py", line 166, in get_session return self.row_to_model(row) File "/usr/lib/python3.4/site-packages/notebook/services/sessions/sessionmanager.py", line 205, in row_to_model raise KeyError KeyError 

deleted-user-3895073 | 10 posts | Feb. 3, 2019, 8:09 p.m. | permalink

Out of curiosity, can you try logging out and logging in again?

Staff

conrad | 4232 posts | PythonAnywhere staff | Feb. 4, 2019, 2:02 p.m. | permalink

@conrad Thanks for the suggestions. I have tried logging out and back in but it did not change anything; I’m getting the same problem.

deleted-user-3895073 | 10 posts | Feb. 4, 2019, 3:46 p.m. | permalink

another thing to check- do you get this error say only at work (vs at home/on a different network)?

Staff

conrad | 4232 posts | PythonAnywhere staff | Feb. 4, 2019, 6 p.m. | permalink

I was getting the error message at home and at work. I deleted all files and tried creating a new notebook. Now I get a new, different error message when creating a notebook. https://ibb.co/mCbN6FX

deleted-user-3895073 | 10 posts | Feb. 6, 2019, 12:35 p.m. | permalink

That sounds like you’re using a notebook that’s not compatible with the version of the system we have installed on PythonAnywhere 🙁

Staff

giles | 11696 posts | PythonAnywhere staff | Feb. 6, 2019, 1:54 p.m. | permalink

Which version is supported? I am getting the error when I try to create a notebook from the Python Anywhere Dashboard.

deleted-user-3895073 | 10 posts | Feb. 6, 2019, 4:04 p.m. | permalink

Oh, I see — that should certainly work. Have you pip installed any Jupyter-related modules into your account?

Staff

giles | 11696 posts | PythonAnywhere staff | Feb. 6, 2019, 7:36 p.m. | permalink

Not that I am aware of. Would it be easier to reset my image and see if that resolves the problem? I have copied the few files I want to keep onto my computer.

deleted-user-3895073 | 10 posts | Feb. 6, 2019, 8:03 p.m. | permalink

One more thing to double check before we go with the nuclear option of resetting everything. When you get the new error message, is that from opening a notebook that you uploaded? Or is it from creating a brand new notebook from our file interface?

Staff

conrad | 4232 posts | PythonAnywhere staff | Feb. 7, 2019, 1:16 p.m. | permalink

When I create a new notebook. I don’t have any existing notebooks to open.

deleted-user-3895073 | 10 posts | Feb. 7, 2019, 5:09 p.m. | permalink

Looking at your running processes from your console tab, I see two processes that were started 2019-02-02. I believe you did not kill the jupyter processes that you thought you had killed. In particular, the processes starting with

/usr/local/bin/python3.4 /usr/bin/jupyterhub-singleuser --user=moonbrain 

Looks like the culprit here. You should stop that process and try again.

Staff

conrad | 4232 posts | PythonAnywhere staff | Feb. 7, 2019, 7:13 p.m. | permalink

Ah! That would also explain why I keep being put in the tarpit! I have killed the processes and will try creating a notebook tomorrow. Thanks for the help.

deleted-user-3895073 | 10 posts | Feb. 7, 2019, 7:53 p.m. | permalink

Hello I have frequently the same issue , i kill all processes , logout / login again but kernel still does not restart. How long should I wait before trying again ? Thanks

deleted-user-4082269 | 15 posts | Jan. 21, 2020, 10:40 a.m. | permalink

Is this with existing and new notebooks? A specific kernel? A specific notebook?

Staff

glenn | 9443 posts | PythonAnywhere staff | Jan. 21, 2020, 12:38 p.m. | permalink

it is with (an) existing notebooks, kernel is python 3.6 , Not a specific notebook : right now , all my notebooks it happens quite frequently.

deleted-user-4082269 | 15 posts | Jan. 21, 2020, 1:26 p.m. | permalink

If it’s the same kernel, try with a different kernel, then we can isolate the cause.

Staff

glenn | 9443 posts | PythonAnywhere staff | Jan. 21, 2020, 5:15 p.m. | permalink

I tried with a 3.5 kernel and I do not get the error, I tried with 3.6 and I get the error. Thank if you can help ?

deleted-user-4082269 | 15 posts | Jan. 22, 2020, 9:54 a.m. | permalink

what happens if you tried with a python3.6 virtualenv? and is this kernel dying when you run the notebook and not restarting afterwards? or is it just never restarting (without having run any cells)

Staff

conrad | 4232 posts | PythonAnywhere staff | Jan. 22, 2020, 3:49 p.m. | permalink

. well you anticipated my next move 😉 I am moving everything in a new venv. I need a bit of time for this.

For your second question : it is never restarting.

Finally I have installed , upgraded many libraries , it broke just after this operation : pip3.6 install —user —upgrade catboost pip3.6 install —user —upgrade ipywidgets pip3.6 install shap pip3.6 install sklearn pip3.6 install —upgrade numpy jupyter nbextension enable —py widgetsnbextension Thanks again for your help

deleted-user-4082269 | 15 posts | Jan. 22, 2020, 4:03 p.m. | permalink

aha- I think that is probably a mismatch between the jupyter / nb ipy widget/extension versions you installed/upgraded to, and the Jupyter versions that we have.

Staff

conrad | 4232 posts | PythonAnywhere staff | Jan. 22, 2020, 5:16 p.m. | permalink

Yes , as a result my python 3.6 kernel is not working anymore, even under a virtual env. I will switch to 3.5 but if there is a way to reset 3.6 i would like to try it. Thanks & best

deleted-user-4082269 | 15 posts | Jan. 23, 2020, 6:54 a.m. | permalink

Did you see the virtualenv link I sent above? I would go to the batteries included page to check your original tornado, ipykernel, and prompt-toolkit versions, and then install those into the virtualenv and ~/.local (from installing with the —user flag)

Staff

conrad | 4232 posts | PythonAnywhere staff | Jan. 23, 2020, 11:57 a.m. | permalink

It’s always a pleasure to hear from you!

Ask us a question, or tell us what you love or hate about PythonAnywhere.
We’ll get back to you over email ASAP.

Recovered from a dead kernel in Jupyter

The best way to keep Jupyter within Data Scientist Workbench healthy is to stop any running notebooks after you’re done with them.

Running notebooks are marked with a lightning bolt in the «Recent Notebooks» sidebar. To stop them, you can expand the twistie icon next to the notebook name and choose «Stop».

You can also go to «File» > «Close and Halt» within Jupyter if you still have the notebook open on your screen.

Once you’ve closed the other notebooks, you can restart your dead kernel by going to «Kernel» > «Restart» within Jupyter.

Новые и зарегистрированные пользователи могут войти

Мы рады что ты здесь

Пожалуйста, войдите, чтобы оставить отзыв

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *