Report this

What is the reason for this report?

KERNEL dies so frequently while running .ipynb using Jupyter Notebook.

Posted on November 3, 2017

from keras.preprocessing import image
from tqdm import tqdm

def path_to_tensor(img_path): # loads RGB image as PIL.Image.Image type img = image.load_img(img_path, target_size=(224, 224)) # convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3) x = image.img_to_array(img) # convert 3D tensor to 4D tensor with shape (1, 224, 224, 3) and return 4D tensor return np.expand_dims(x, axis=0)

def paths_to_tensor(img_paths): list_of_tensors = [path_to_tensor(img_path) for img_path in tqdm(img_paths)] return np.vstack(list_of_tensors)```

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

pre-process the data for Keras

train_tensors = paths_to_tensor(train_files).astype(‘float32’)/255 valid_tensors = paths_to_tensor(valid_files).astype(‘float32’)/255 test_tensors = paths_to_tensor(test_files).astype(‘float32’)/255

```The error mesg. - "Kernel Restarting

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

From Jupyter notebook log please find below the snapshot and see how frequently the kernel is getting stopped in between - 

**[I 06:53:09.792 NotebookApp] Kernel started: 1a6cc3fd-6f08-493e-9276-b6c79b186ec0**
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
[I 06:55:10.347 NotebookApp] Saving file at /dog_app.ipynb
**[I 06:55:42.814 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 06:57:10.327 NotebookApp] Saving file at /dog_app.ipynb
[I 06:59:12.226 NotebookApp] Saving file at /dog_app.ipynb
**[I 06:59:57.833 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 07:01:10.341 NotebookApp] Saving file at /dog_app.ipynb
**[I 07:02:33.857 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 07:03:10.331 NotebookApp] Saving file at /dog_app.ipynb
[I 07:05:10.009 NotebookApp] Saving file at /dog_app.ipynb
**[I 07:06:03.874 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**




This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello there,

I will highly recommend examining the resource usage on the droplet. In case of a basic droplet it can simply run out of resources and causing the problems that you report.

Adding SWAP space on the droplet is a must in order to have better performance. Make sure to check the system logs as this can provide additional information on the kernel issues.

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

You can check this article on how to monitor the droplet resource usage

https://www.digitalocean.com/community/tutorials/how-to-monitor-cpu-use-on-digitalocean-droplets

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.