更新:最後製作自定義鏡像時發現一個非常不合理的現象。就是製作的鏡像只會保存你安裝的那些軟件包,包括pandas/sklearn/matplotlib和jupyter notebook的配置。但是tensorflow/keras和原有的顯卡驅動竟然沒有保存到自定義鏡像中!!!所以貌似只能每次購買實例時都重複以下步驟。。。
配置實例時從鏡像市場選擇預裝tensorflow和顯卡驅動的系統。
該系統預裝了tensorflow 1.3.0以及對應顯卡驅動、CUDA和cuDNN。購買配有GPU的實例後只需要配置jupyter notebook和其他軟件包。
查看tensorflow版本
python
import tensorflow as tf
tf.__version__
tf.__path__
# python 2.7.5
# tensorflow 1.3.0
安裝和配置遠程訪問jupyter notebook
# 安裝jupyter notebook
python -m pip install jupyter
# 配置遠程訪問文件
jupyter notebook --generate-config --allow-root
# 會生成文件 /root/.jupyter/jupyter_notebook_config.py
# 設置jupyter密碼
python
from notebook.auth import passwd
passwd()
'xxxxxxxxxxxxxxxxxxxxxxx密碼串xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
exit()
# 在遠程訪問配置文件加入
vim /root/.jupyter/jupyter_notebook_config.py
i
c.NotebookApp.ip = '*'
c.NotebookApp.password = 'xxxxxxxxxxxxxxxxxxxxxxxxxx密碼串xxxxxxxxxxxxxxxxxxxxxxxxxx'
c.NotebookApp.port= 8888
c.NotebookApp.notebook_dir = "/root/"
c.NotebookApp.allow_remote_access = True
c.NotebookApp.open_browser = False
esc
:wq
# 遠程訪問
jupyter notebook --allow-root
# 瀏覽器輸入服務器公共IP:8888訪問
Ctrl+C
安裝其他軟件包
pip install pandas
pip install scikit-learn
# pip install matplotlib出錯
yum install python-devel
pip install matplotlib
# 安裝tensorflow版本對應的keras
pip install keras==2.0.6
# h5py用於保存模型
pip install h5py
測試是否安裝成
以上。