简体   繁体   English

Jupyter:如何列出正在运行的内核以及哪个笔记本启动了它们?

[英]Jupyter: How to list running kernels and which notebook started them?

I haven't found answers in github or in the jupyter help.我没有在 github 或 jupyter 帮助中找到答案。

TL;DR : I need a command-line that tells me the same thing as the %connect_info magic, in particular the line Connect with --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json . TL;DR :我需要一个命令行来告诉我与%connect_info魔术相同的内容,尤其是Connect with --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json

My current setup is to have the jupyter notebook launched from a work server.我当前的设置是让 jupyter notebook 从工作服务器启动。 Then I connect to that server with SSH, and can work in the same kernel by attaching a console to it:然后我使用 SSH 连接到该服务器,并且可以通过将控制台附加到它来在同一个 kernel 中工作:

jupyter console --existing kernel-4e4c970e-cccb-2485-a09d-d56efd10e278.json

(in a tmux + vim + slimux setup, which by the way I often find more convenient). (在tmux + vim + slimux设置中,顺便说一下,我经常觉得这更方便)。

The problem is:问题是:

  1. The only way to get the kernel string is from the notebook itself (which may be difficult to access over SSH);获取 kernel 字符串的唯一方法是从笔记本本身(可能难以通过 SSH 访问);
  2. I have several notebook runnings, sometimes I need to quickly check which one I need.我有几个笔记本运行,有时我需要快速检查我需要哪一个。

So is there a command to run from the shell on the server, that would list running kernels , which notebook launched them , and ideally if there are consoles attached ?那么是否有从服务器上的 shell 运行的命令,它会列出正在运行的内核哪个笔记本启动了它们,理想情况下是否连接了控制台

You can list the kernel json files sorted by time with:您可以列出按时间排序的 kernel json 文件:

ls -tlr ~/.local/share/jupyter/runtime/

-rw------- 1 user user 263  6. Dez 13:40 kernel-c64635b5-6f5c-4938-828b-520d70e2a6c4.json
-rw------T 1 user user 263  7. Dez 11:57 kernel-1bdb41b4-1e87-4672-af92-7c3f3660e19c.json
-rw------T 1 user user 263  7. Dez 16:48 kernel-f7a51511-8c2a-4f0b-9cd3-6e5a79dccab3.json

This will not give you the information about which notebook launched them and if there is a console attached.这不会为您提供有关哪个笔记本启动它们以及是否连接了控制台的信息。 But the times will give you some hints of which kernel is the one you are looking for, and with some trial and error you will figure it out.但是时代会给你一些提示,告诉你 kernel 是你要找的那个,通过一些试验和错误你会弄明白的。

This answer is based on the blog post “Connecting with Ipython from the command line to a running Jupyter session” by DS4N6.此答案基于 DS4N6 的博客文章“Connecting with Ipython from the command line to a running Jupyter session”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jupyter Notebook停止在AWS服务器上运行 - Jupyter notebook stopped running on AWS server 如何通过 ssh 访问远程服务器上运行的 Jupyter notebook 中本地机器的输入设备? - How to access input device of local machine in Jupyter notebook running on remote server through ssh? 列出正在运行的 Jupyter 笔记本和令牌 - List running Jupyter notebooks and tokens 创建到运行Jupyter Notebook的远程Docker容器的ssh隧道 - Create ssh tunnel to remote docker container running Jupyter Notebook 当 SSH 在本地机器上终止时,让 jupyter lab notebook 保持运行? - Keep jupyter lab notebook running when SSH is terminated on local machine? 在远程服务器的后台运行 Jupyter Notebook,获取输出 - Running Jupyter Notebook in the background on remote server, get output 如何在本地计算机上自动初始化远程Jupyter笔记本? - How to automate initialization of a remote Jupyter notebook on local machine? VSCode:如何通过远程服务器在 docker 容器中运行 Jupyter notebook? - VSCode: How to run a Jupyter notebook in a docker container, over a remote server? 在tmux中运行远程Jupyter Notebook时无法关闭SSH连接 - Unable to close ssh-connection while running a remote Jupyter Notebook in tmux 套接字错误-OSError:[Errno 99]-在远程主机上运行Jupyter笔记本 - Socket Error - OSError: [Errno 99] - Running Jupyter-notebook on remote host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM