Jupyter Notebook远程网页显示

本文介绍了在TAMU-ada服务器上加载和运行jupyter lab服务,在本机网页端进行操作和使用。注意前提是本机应处于校园网内,否则需要开启校园vpn。

1.在服务器端开启服务

以TAMU-ada服务器为例

# 在.bashrc文件中添加几条alias,并激活
alias ana35='module load Anaconda/3-5.0.0.1'
alias jn='jupyter notebook'
alias jupyter='jupyter lab --no-browser --port=8737'
# 载入模块Anaconda
ana35
# 服务器端运行jupyter notebook或lab,推荐lab
jupyter
# 届时将会显示
[hengkai.yao@ada1 ~]$ jupyter
[I 17:52:22.610 LabApp] JupyterLab alpha preview extension loaded from /software/hprc/Anaconda/3-5.0.0.1/lib/python3.6/site-packages/jupyterlab
JupyterLab v0.27.0
Known labextensions:
[I 17:52:22.665 LabApp] Running the core application with no additional extensions or settings
[I 17:52:22.676 LabApp] Serving notebooks from local directory: /general/home/hengkai.yao
[I 17:52:22.677 LabApp] 0 active kernels
[I 17:52:22.677 LabApp] The Jupyter Notebook is running at: http://localhost:8737/?token=0b3b4a56621370cd607fd6a82d21c2f8a7088799d39b161d
[I 17:52:22.677 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:52:22.679 LabApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8737/?token=0b3b4a56621370cd607fd6a82d21c2f8a7088799d39b161d
# 保持该屏token稍后将被用于登录网页

2.本地端口转发

再开一个终端用于ssh端口转发

# 建议将以下语句保存在本地.bashrc里
# 8737端口应与上面的服务器端相同,8888端口可自定
ssh -N -L localhost:8888:localhost:8737 hengkai.yao@ada.tamu.edu
# 输入密码后终端不反回任何信息
# 保持该屏

3.本地网页加载

网址处输入localhost:8888,其中端口8888应与上文转发的端口号一致。
进入网页后输入token值来登录页面。

Last modification:September 18th, 2019 at 06:09 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment