🐈

【ML】How monitor Jupyter Notebook progress in the background

2024/07/28に公開

1. Problem

When running a machine learning model in Jupyter Notebook, if you are using VSCode, there is an issue where print() and progress bars are not displayed when the model goes into the background.

1.1 solution

To solve this you can use the following command:

・Install

pip install nbconvert

・How to

jupyter nbconvert --to notebook --execute your_notebook.ipynb

This code runs the .ipynb file. After running .ipynb file, you will see the outputs directly beneath each code cell that was executed.

The command will overwrite the original notebook file (your_notebook.ipynb) with the executed version.
All the outputs (e.g., printed statements, a result of code execution, generated plots) will be embedded in the corresponding cells of the notebook.

1.2 another way

If you want to keep the original notebook unchanged and save the executed version as a new file, you can specify an output file name:

jupyter nbconvert --to notebook --execute --output executed_notebook.ipynb your_notebook.ipynb

This will save the executed notebook as executed_notebook.ipynb, leaving the original file unchanged.

I'm grad this article helps someone.

Discussion