【问题标题】:Run Jupyter Notebook from SSH to remote server node从 SSH 运行 Jupyter Notebook 到远程服务器节点
【发布时间】:2022-01-12 10:35:32
【问题描述】:

我想从 SSH 运行一个 jupyter notebook 到远程服务器节点。 步骤:

  1. ssh user@remote.server
  2. jupyter notebook --no-browser --port=8887

我的电脑上的步骤:

  1. ssh -N -L localhost:8888:localhost:8887 user@remote.server
  2. 运行 localhost:8888

这很好用。但是我想在 user@remote.server 内的 node1 上运行它,因为 node1 包含一个 GPU。

我所做的步骤是相似的,除了这个: ssh -N -L localhost:8888:localhost:8887 user@remote.server "ssh node1"

但这不起作用:“通道 2:打开失败:连接失败:连接被拒绝”

编辑:/etc/hosts:

根据@ajz34的回答,多次尝试后的解决方案:

  1. 在 node1 上:jupyter notebook --no-browser --port=8886 --ip=127.0.0.1
  2. 在服务器上:ssh -N -L 8887:127.0.0.1:8886 node1
  3. 在本地:ssh -N -L 8888:127.0.0.1:8887 user@xxx.xxx.xxx.xxx

【问题讨论】:

    标签: ssh jupyter-notebook gpu remote-server


    【解决方案1】:

    我认为一个可能的简单解决方案是添加一个中间 ssh 连接。

    假设您的工作流程是计算机 -> 服务器(访问节点)-> node1(计算节点),那么

    • 从user@remote.node1,执行

      jupyter notebook --no-browser --port=8886

    • 从user@remote.server,执行

      ssh -N -L localhost:8887:localhost:8886 user@remote.node1

    • 在您的计算机上执行

      ssh -N -L localhost:8888:localhost:8887 user@remote.server

      然后在您的计算机浏览器上运行 localhost:8888。

    从@CasellaJr 的解析来看,也许对于不同的服务器,您可能希望将localhost 显式更改为127.0.0.1[::1] 或其他可能有效的地址。

    【讨论】:

    • 如果计算节点(node1)无法分配请求的localhost地址,在jupyter notebook ...后面加上--ip=127.0.0.1可以避免这个问题。我刚刚在我的 HPC 环境中遇到了这个问题。
    • 我还找到了stackoverflow.com/a/60431456/7740992。如果计算节点不能通过 ssh 访问,但可以通过 LSF 访问,则需要 LSF 脚本。
    • 我继续有这个错误:通道2:打开失败:连接失败:连接被拒绝
    • 可以肯定的是,我已经这样做了:在我的 node1 的 conda 环境中:jupyter notebook --no-browser --port=8886 --ip=127.0.0.1 然后在我的服务器中:ssh -N -L localhost:8887:localhost:8886 user@ip node1 和我的本地 PC 上:ssh -N -L localhost:8888:localhost:8887 user@ip
    • 我认为我已经听从了您的建议,但它不起作用。注意错误channel 2: open failed: connect failed: Connection refused出现在我写ssh -N -L localhost:8887:localhost:8886 user@ip node1的终端上
    猜你喜欢
    • 2018-09-21
    • 2019-07-01
    • 2018-01-31
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2020-03-17
    相关资源
    最近更新 更多