dhazra
By:
dhazra

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

November 3, 2017 117 views
DigitalOcean Python Ubuntu 16.04

from keras.preprocessing import image

from tqdm import tqdm

def pathtotensor(imgpath):
# loads RGB image as PIL.Image.Image type
img = image.load
img(imgpath, targetsize=(224, 224))
# convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3)
x = image.imgtoarray(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 pathstotensor(imgpaths):
list
oftensors = [pathtotensor(imgpath) for imgpath in tqdm(imgpaths)]
return np.vstack(listoftensors)```

from PIL import ImageFile

ImageFile.LOADTRUNCATEDIMAGES = True

pre-process the data for Keras

traintensors = pathstotensor(trainfiles).astype('float32')/255
validtensors = pathstotensor(validfiles).astype('float32')/255
testtensors = pathstotensor(testfiles).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**
1 comment
  • One more point I would like to mention that the same .ipynb file with the same environment setup is running absolutely fine with Jupyter Notebook in Amazon Web Service (AWS) environment. So, there is no problem in .ipynb file, that much I can assure everyone who looks into this issue. It is the pure environment issue with the environment setup in DigitalOcean. But I couldn't understand, where the issue comes from actually.

    Thanks

    • Debasish Hazra
Be the first one to answer this question.