LoginSignup
80
44

More than 5 years have passed since last update.

Jupyter notebook をコマンドラインで実行する

Last updated at Posted at 2018-06-11

Jupyter notebook をコマンドラインで実行したいことがあると思います。例えば

  • Jupyter notebook は長時間実行すると切れることがあって嫌だ
  • Jupyter notebook を自動テストしたい

その場合、jupyter nbconvert --to notebook --executeを使うと実行できます。

$ jupyter nbconvert --to notebook --execute mynotebook.ipynb \
    --output mynotebook2.ipynb --ExecutePreprocessor.timeout=2678400 \
     --allow-errors --debug
  • --ExecutePreprocessor.timeout=2678400 は各セル当たりのタイムアウト時間(秒)を設定しています。デフォルトだと30秒なので、機械学習で使うには短すぎます。2678400秒は31日です。
  • --debug はどのセルまで実行したかを見るためにつけた方が良いです。つけないと、ちゃんと実行できているのか分からず、結構困ります。

※ そのうち、Google Colaboratory でお試し学習したものを、GCP/AWS上でjupyter nbconvert --to notebook --executeを使って本格的に学習する流れを書きます。

80
44
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
80
44