更新:最后制作自定义镜像时发现一个非常不合理的现象。就是制作的镜像只会保存你安装的那些软件包,包括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
测试是否安装成
以上。