When you are running a Code Cell in a jupyter notebook which produces a lot of logs (eg: printing a progress bar during the training) your browser window could crash. This is a long standing issue from Jupyter that JupyterLab has inherited. Unfortunately the experience is really similar to the one you get from an Out Of Memory error, with the exception that in this scenario the Kernel is still running the code!

Here are some workarounds that you can use on Keras:

  • Change the verbosity of your code. E.g. the Keras fit  API provides a parameter for this purpose:
# Verbose: Integer. 0, 1, or 2.
# Verbosity mode: 0 = silent, 1 = # progress bar, 2 = one line per epoch.

history = model.fit(x=X_train,
                    y=Y_train,
                    batch_size=256,
                    epochs=10,
                    verbose=2)
import sys
sys.stdout = open('keras_training.txt', 'w')

history = model.fit(x=X_train,
                    y=Y_train,
                    batch_size=256,
                    epochs=10,
                    verbose=2)

sys.stdout = sys.__stdout__

Then you can track the progress in real time by opening a Terminal and running:

$ tail -f keras_training.txt
  • Use the tqdm_notebook API as a progress bar in your notebook. There is a nice callback that you can use on Keras:
from keras_tqdm import TQDMCallback

history = model.fit(x=X_train,
                    y=Y_train,
                    batch_size=256,
                    epochs=10,
                    verbose=0,
                    callbacks=[TQDMCallback()])

Note: You will have to install tqdm_notebook and keras_tqdm  as external python dependencies.

If you are experiencing the same issue with a different framework, please reach us out!

Did this answer your question?