k8s+tensorflow+keras+jupyter部署
参考链接:https://blog.csdn.net/weixin_40008349/article/details/81135847一、使用docker命令拉取tensorFlow镜像docker pull tensorflow/tensorflow:latest二、使用dockerrun 命令 创建容器运行新下载的tensorflow镜像docker run -it tensor...
参考链接:https://blog.csdn.net/weixin_40008349/article/details/81135847
一、使用docker命令拉取tensorFlow镜像
docker pull tensorflow/tensorflow:latest
二、使用docker run 命令 创建容器运行新下载的tensorflow镜像
docker run -it tensorflow:latest  /bin/bash
三,在 运行的容器中使用pip安装keras和jupyter notebook
pip install keras
pip install jupyter notebook
四、在运行的容器中 输入 python,打开python环境
python
五、在python命令行中输入
from notebook.auth import passwd
passwd()
之后按照提示设置自己jupyter的登录密码
  完成之后会生成一个sha1秘钥,保存下来
  输入exit(),退出python环境
exit()
六、输入以下命令,生成jupyter notebook的配置文件
jupyter notebook --generate-config
我的环境会在容器的root下生成一个配置文件 /root/.jupyter/jupyter_notebook_config.py
  然后修改jupyter_notebook_config.py,加入以下内容
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:cb8d37daab4f:5c2cf23085e15e472c251bc3a6c738cf89284f7a'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888
七、使用docker commit命令将此容器打包成一个新的镜像
 docker commit -m "" -a ""  [containerID]  [Imagename]
八、创建一个新的 ts-jupyter.yml 文件,并写入以下内容
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: tensor
spec:
  selector:
    matchLabels:
      app: tensor
  template:
    metadata:
      labels:
        app: tensor
    spec:
      containers:
      - name: tensor
        image: ts-jupyter               #ts-jupyter是包含tensorflow+keras+jupyter的镜像的名字
        imagePullPolicy: IfNotPresent
        ports:
        - name: http
          containerPort: 8888
        command: ["/bin/bash"]                        #容器启动命令,进入容器的shell终端
        args: ["-c","jupyter notebook --allow-root"]  #启动jupyter notebook
---
apiVersion: v1
kind: Service
metadata:
  name: tensor
spec:
  ports:
  - name: http
    port: 8888
    nodePort: 31006                             #jupyter notebook对外暴露服务的端口号
    protocol: TCP
  selector:
    app: tensor
  type: NodePort
九、在浏览器中输入 ip+31006端口号即可访问jupyter notebook。
更多推荐
 


所有评论(0)