首页 > 解决方案 > 从所述笔记本中关闭一个 jupyter 笔记本

问题描述

我在服务器上运行的 jupyter 笔记本中工作。我经常让我的繁重代码在一夜之间运行。我想在我的代码完成后释放服务器内存,以便其他人可以在早上工作。我正在考虑放置一些代码来释放内存/在最后一块中关闭笔记本。

我将如何实现这一目标?您是否看到另一个更相关的行动方案?

标签: pythonjupyter-notebook

解决方案


github 讨论中提出了以下解决方案:

%%javascript
require(
    ["base/js/dialog"], 
    function(dialog) {
        dialog.modal({

                title: 'Notebook Halted',
                body: 'This notebook is no longer running; the kernel has been halted. Close the browser tab, or, to continue working, restart the kernel.',
                buttons: {
                    'Kernel restart': { click: function(){ Jupyter.notebook.session.restart(); } }
                }
        });
    }
);
Jupyter.notebook.session.delete();

推荐阅读