跳转至

本地打开远程

打开远程服务器端的tensorboard

https://blog.csdn.net/Leon1997726/article/details/118498462

  1. 远程端启动tensorboard并指定端口, 注意必须在log文件夹的上一级tensorboard --logdir ./ --port 6006
  2. 本地端ssh远程连接服务器,ssh -p 35009 -L 16006:127.0.0.1:6006 sunshuqing@202.38.88.88,其中16006制定了本地端口
  3. 本地浏览器输入 http://127.0.0.1:16006/ 即可访问tensorboard

打开远程jupyter notebook

https://blog.csdn.net/u013317445/article/details/107684528 https://blog.csdn.net/m0_43609475/article/details/120004904

  1. 远程端安装conda环境中安装jupyter,切换到指定conda环境,pip install jupyter
  2. 配置远程端jupyter config:

    Bash
    jupyter notebook --generate-config # 配置文件存放地址~/.jupyter/jupyter_notebook_config.py
    # 进入python
    >>>from notebook.auth import passwd
    >>>passwd() #记录密码
    vim ~/.jupyter/jupyter_notebook_config.py
    c.NotebookApp.ip='*' # 就是设置所有ip皆可访问
    c.NotebookApp.password = 'sha1:72… ' # 刚生成的那个密钥
    c.NotebookApp.open_browser = False # 禁止自动打开浏览器
    c.NotebookApp.port =8888 # 随便指定一个端口
    c.NotebookApp.allow_remote_access  = True  # 允许远程访问 
    
  3. 本地端ssh远程连接服务器,ssh -p 35009 -L 8888:127.0.0.1:8888 sunshuqing@202.38.88.88,其中8888制定了本地端口

  4. jupyter 代码自动补全:

    Bash
    pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple/
    jupyter contrib nbextension install --user
    pip install jupyter_nbextensions_configurator -i https://pypi.mirrors.ustc.edu.cn/simple/
    jupyter nbextensions_configurator enable --user
    
  5. jupyter notebook选择conda环境: conda install nb_conda_kernels

  6. 后台运行:直接以 jupyter notebook 命令启动 Jupyter 的方式在连接断开时将会中断,所以我们需要让 Jupyter 服务在后台常驻。nohup jupyter notebook > ~/.jupyter/jupyter.log 2>&1 &
  7. 关闭后台运行jupyter:

    Bash
    ps -aux | grep jupyter
    #一般会看到两个程序,杀死/home/sunshuqing/anaconda3/envs/agent57/bin/jupyter-notebook
    kill -9 PID
    
  8. 但是这都建立在本地使用了ssh命令连接远程并映射端口,如果连接终端,则不能使用jupyter notebook


最后更新: September 24, 2022
Back to top