运行 GCP 虚拟机上的 MLFlow

Running MLFlow on GCP VM

我已经在 GCP VM 实例上安装了 mlflow, 现在我想用外部 IP 访问 mlflow UI。 我尝试设置防火墙规则并打开 mlflow 的默认端口,但无法访问它。 有人可以为 VM 实例上的 运行 mlflow 提供分步过程吗?

我决定检查我的测试 VM 和 运行 GCE VM 上的 mlflow 服务器。看看我下面的步骤:

  1. 基于 Ubuntu Linux 18.04 LTS
  2. 创建 VM 实例
  3. install MLflow:

    $ sudo apt update
    $ sudo apt upgrade
    $ cd ~
    $ git clone https://github.com/mlflow/mlflow
    $ cd mlflow
    $ sudo apt install python3-pip
    $ pip3 install mlflow
    $ python3 setup.py build
    $ sudo python3 setup.py install
    $ mlflow --version
    mlflow, version 1.7.1.dev0
    
  4. 运行 VM 实例内部 IP 上的 mlflow 服务器(默认 127.0.0.1):

    $ ifconfig 
    ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1460
    inet 10.XXX.15.XXX  netmask 255.255.255.255  broadcast 0.0.0.0
    ...
    
    $ mlflow server --host 10.XXX.15.XXX
    [2020-03-09 15:05:50 +0000] [8631] [INFO] Starting gunicorn 20.0.4
    [2020-03-09 15:05:50 +0000] [8631] [INFO] Listening at: http://10.128.15.211:5000 (8631)
    [2020-03-09 15:05:50 +0000] [8631] [INFO] Using worker: sync
    [2020-03-09 15:05:50 +0000] [8634] [INFO] Booting worker with pid: 8634
    [2020-03-09 15:05:51 +0000] [8635] [INFO] Booting worker with pid: 8635
    [2020-03-09 15:05:51 +0000] [8636] [INFO] Booting worker with pid: 8636
    [2020-03-09 15:05:51 +0000] [8638] [INFO] Booting worker with pid: 8638
    
  5. 从 VM 实例(从第二个连接)检查:

    $ curl -I http://10.XXX.15.XXX:5000
    HTTP/1.1 200 OK
    Server: gunicorn/20.0.4
    Date: Mon, 09 Mar 2020 15:06:08 GMT
    Connection: close
    Content-Length: 853
    Content-Type: text/html; charset=utf-8
    Last-Modified: Mon, 09 Mar 2020 14:57:11 GMT
    Cache-Control: public, max-age=43200
    Expires: Tue, 10 Mar 2020 03:06:08 GMT
    ETag: "1583765831.3202355-853-3764264575"
    
  6. set network tag mlflow-server

  7. create firewall rule 允许访问端口 5000

    $ gcloud compute --project=test-prj firewall-rules create mlflow-server --direction=INGRESS --priority=999 --network=default --action=ALLOW --rules=tcp:5000 --source-ranges=0.0.0.0/0 --target-tags=mlflow-server
    
  8. 从本地 Linux 计算机 nmap -Pn 35.225.XXX.XXX

    检查
    Starting Nmap 7.80 ( https://nmap.org ) at 2020-03-09 16:20 CET
    Nmap scan report for 74.123.225.35.bc.googleusercontent.com (35.225.XXX.XXX)
    Host is up (0.20s latency).
    Not shown: 993 filtered ports
    PORT     STATE  SERVICE
    ...
    5000/tcp open   upnp
    ...
    
  9. 转到网络浏览器http://35.225.XXX.XXX:5000/