jupyter 遠程訪問


Jupyter 遠程訪問

jupyter 遠程訪問的工作方法是,在本地通過瀏覽器打開jupyter,但是代碼和服務運行在遠程集群中。

集群設置

首先需要確保集群中安裝有python和jupyter。
在集群 /opt/intel/2019 目錄下,已經安裝好python3和jupyter。將其添加入環境變量中

export PATH=/opt/intel/2019/intelpython3/bin:${PATH}

隨后對python路徑進行檢查,可以看出此時已經在調用intel python。

$ which python
/opt/intel/2019/intelpython3/bin/python

隨后用以下命令對 jupyter 進行設置,設置 jupyter 登錄密碼。

$ jupyter notebook --generate-config

$ jupyter notebook password
Enter password:  ****
Verify password: ****

此時在個人目錄下就生成了 jupyter 配置文件 jupyter_notebook_config.py
對配置文件進行修改,增加以下設置

c.NotebookApp.ip='*' # 星號代表任意ip,這個跟mysql的權限設置一樣,所以說知識是互通的
c.NotebookApp.allow_remote_access = True # 允許遠程連接
c.NotebookApp.password = u'sha1:xxx' # 復制密碼在此 
c.NotebookApp.open_browser = False # 不自動打開瀏覽器
c.NotebookApp.port = 6666 # 指定端口, 訪問時使用

注意在設置端口時給定一個較大的整數,22 或 24 等常用端口時不可以的。
此時即可在命令行中啟動jupyter notebook服務,會顯示以下內容:

$ jupyter notebook
[W 14:01:28.051 NotebookApp] Collisions detected in /home/lilongxiang/.jupyter/jupyter_notebook_config.py and /home/lilongxiang/.jupyter/jupyter_notebook_config.json config files. /home/lilongxiang/.jupyter/jupyter_notebook_config.json has higher priority: {
      "NotebookApp": {
        "password": "'sha1:llx891209' ignored, using 'sha1:a221858aea95:923e3211599640af335a06052fcea5818f118621'"
      }
    }
[W 14:01:28.054 NotebookApp] Config option `allow_remote_access` not recognized by `NotebookApp`.  Did you mean one of: `allow_credentials, allow_root`?
[W 14:01:28.206 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 14:01:28.213 NotebookApp] Serving notebooks from local directory: /home/lilongxiang
[I 14:01:28.213 NotebookApp] 0 active kernels
[I 14:01:28.213 NotebookApp] The Jupyter Notebook is running at:
[I 14:01:28.213 NotebookApp] http://[all ip addresses on your system]:1224/
[I 14:01:28.213 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 14:01:41.532 NotebookApp] 302 GET / (10.155.11.18) 0.50ms

本地登錄

注意上面內容中,提示可以使用任意ip地址登錄Notebook服務。在本地網頁瀏覽器中,以集群IP地址代替。如集群IP為10.166.15.60,在本地瀏覽器中輸入

https://10.166.15.60:1224/

隨后即可登錄集群jupyter notebook服務進行操作。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM