Jupyter Notebook是很是優秀的開發環境,在Ubuntu服務器中,啓動服務,經過瀏覽器開發,同時可視化執行.ipynb文件,這樣就能夠使用GPU直接執行深度學習的算法。python
環境:算法
關鍵點:shell
建立virtualenv虛擬環境,在虛擬環境中,安裝Jupyter:瀏覽器
pip install jupyter
複製代碼
建立密匙,密匙就是jupyter的登陸密碼,生成sha1的加密字符串:bash
>> from notebook.auth import passwd
>> passwd()
Enter password:
Verify password:
'sha1:xxx'
複製代碼
編輯配置文件,命名爲:jupyter_config.py服務器
c.NotebookApp.ip = 'localhost' # 指定
c.NotebookApp.open_browser = False # 關閉自動打開瀏覽器
c.NotebookApp.port = 8812 # 端口隨意指定
c.NotebookApp.password = u'sha1:xxxx' # 複製前一步生成的密鑰
複製代碼
啓動Jupyter服務:jupyter notebook --config=jupyter_config.py
ssh
(mlp3_p37_venv) xxx@xxxx:/data1/wcl/workspace$ jupyter notebook --config=jupyter_config.py
[I 17:14:01.262 NotebookApp] Serving notebooks from local directory: /data1/wcl/workspace
[I 17:14:01.262 NotebookApp] The Jupyter Notebook is running at:
[I 17:14:01.262 NotebookApp] http://localhost:8812/
[I 17:14:01.262 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
複製代碼
nohup版本的啓動命令:學習
nohup jupyter notebook --config=jupyter_config.py &
複製代碼
本地鏈接服務器的方式爲:.ssh/config
測試
Host gateway
HostName xx.xx.xx.xxx
User xxx
Port xxxxx
Host 3
User xxx
HostName xxx.xx.xx.3
ProxyCommand ssh -q -W %h:%p gateway
複製代碼
執行以下命令,其中:this
ssh -N -f -L localhost:8812:localhost:8812 xxx@3
複製代碼
前面的是本地端口,後面的是遠程端口,xxx是用戶名,3是服務器。
這個命令也能夠寫入至系統環境中,每次啓動shell都會自動執行。
本地瀏覽器中,輸入:http://localhost:8812
在開發中,須要使用虛擬環境,所以須要在Jypyter中,增長虛擬環境。
命令以下:
(mlp3_p37_venv) xxx@3:/data/workspace$ ipython kernel install --user --name=mlp3_p37_venv
複製代碼
測試Python的版本:
OK, that's all!