如何安全关闭mlflow ui?

ski*_*bee 5 python r machine-learning mlflow

mlflow ui远程服务器上运行后,我无法mlflow ui再次重新打开。
一种解决方法是使用pkill -u MyUserName.
否则我会收到以下错误:

[INFO] Starting gunicorn 20.0.4  
[ERROR] Connection in use: ('127.0.0.1', 5000)
[ERROR] Retrying in 1 second.  
...
Running the mlflow server failed. Please see ther logs above for details.
Run Code Online (Sandbox Code Playgroud)

我理解错误,但我不明白:
1. 关闭的正确方法是什么mlflow ui
2. 如何识别mlflow ui进程以便仅终止该进程而不使用pkill

目前我关闭浏览器或使用 ctrl+C

小智 9

mlflow ui我最近在调用远程服务器时也遇到了类似的问题。在命令行Ctrl + C中退出通常有效。但是,如果没有,使用pkill -f gunicorn可以解决我的问题。注意,您也可以使用ps -A | grep gunicorn先查找进程并kill [PID]手动进行。类似的问题似乎已经在这里讨论过一次。


joe*_*ler 6

如果您无法连接到 mlflow,因为它已经在运行,您可以运行以下命令来终止 UI 以生成另一个 UI:

\n
lsof -i :5000\n
Run Code Online (Sandbox Code Playgroud)\n

另外,-port如果您需要启动多个 UI,您可以使用 MLFlow 来分配一个端口号,以防止混淆;例如,一个用于跟踪,一个用于服务等。默认情况下,服务器在端口 5000 上运行。如果该端口已在使用中,请使用该\xe2\x80\x93port选项指定不同的端口:

\n
mlflow models serve -m runs:/<RUN_ID>/model --port 1234\n
Run Code Online (Sandbox Code Playgroud)\n

2022 年 6 月更新: \n您可以在此处向此 cmd 添加--port标志以正确设置 MLFlow:如何开始使用 MLflow SQL 存储而不是文件系统存储?

\n


小智 5

我收到mlflow ui命令错误。

错误是

[2022-04-19 10:48:02 -0400] [89933] [INFO] Starting gunicorn 20.1.0
[2022-04-19 10:48:02 -0400] [89933] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-04-19 10:48:02 -0400] [89933] [ERROR] Retrying in 1 second.
[2022-04-19 10:48:03 -0400] [89933] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-04-19 10:48:03 -0400] [89933] [ERROR] Retrying in 1 second.
[2022-04-19 10:48:04 -0400] [89933] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-04-19 10:48:04 -0400] [89933] [ERROR] Retrying in 1 second.
[2022-04-19 10:48:05 -0400] [89933] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-04-19 10:48:05 -0400] [89933] [ERROR] Retrying in 1 second.
[2022-04-19 10:48:06 -0400] [89933] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2022-04-19 10:48:06 -0400] [89933] [ERROR] Retrying in 1 second.
[2022-04-19 10:48:07 -0400] [89933] [ERROR] Can't connect to ('127.0.0.1', 5000)
Run Code Online (Sandbox Code Playgroud)

对我有用的解决方案:

步骤一:获取进程id

ps -A | grep gunicorn

20734 ?? 0:39.17 /usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python /Users/XXX/env/bin/gunicorn - b 127.0.0.1:5000 -w 1 mlflow.server:app

步骤 2:从最后的输出中获取PID ,并终止具有正在使用该端口的 PID 的进程

kill 20734


Jul*_*mji 0

默认情况下,mlflow UI 绑定到端口 5000,因此后续调用将导致端口繁忙错误。

您可以启动多个 MLflow ui 并提供不同的端口号:

Usage: mlflow ui [OPTIONS]

  Launch the MLflow tracking UI for local viewing of run results. To launch
  a production server, use the "mlflow server" command instead.

  The UI will be visible at http://localhost:5000 by default, and only
  accept connections from the local machine. To let the UI server accept
  connections from other machines, you will need to pass ``--host 0.0.0.0``
  to listen on all network interfaces (or a specific interface address).

Options:
  --backend-store-uri PATH     URI to which to persist experiment and run
                               data. Acceptable URIs are SQLAlchemy-compatible
                               database connection strings (e.g.
                               'sqlite:///path/to/file.db') or local
                               filesystem URIs (e.g.
                               'file:///absolute/path/to/directory'). By
                               default, data will be logged to the ./mlruns
                               directory.
  --default-artifact-root URI  Path to local directory to store artifacts, for
                               new experiments. Note that this flag does not
                               impact already-created experiments. Default:
                               ./mlruns
  -p, --port INTEGER           The port to listen on (default: 5000).
  -h, --host HOST              The network address to listen on (default:
                               127.0.0.1). Use 0.0.0.0 to bind to all
                               addresses if you want to access the tracking
                               server from other machines.
  --help                       Show this message and exit.```

Try it and see what happens.

Run Code Online (Sandbox Code Playgroud)