-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
k8s 运行分布式 tensorflow 实验 #5
Comments
kubectl create -f nfs-server 应该是kubectl create -f nfs-server-local.yaml,别的没问题 |
已修正问题. |
|
|
回答相关问题
|
k8s 使用 cephfs 创建 PersistentVolume实验基于:
下面是流程描述和注意事项 准备工作正常运行的 ceph 集群:
创建 ceph 的 PersistentVolume 和 PersistentVolumeClaim创建 ceph-pvc.yaml, 添加下面内容, 需要替换
apiVersion: v1
kind: Secret
metadata:
name: ceph-secret
data:
key: QVFCcHphMVhJbm5pRlJBQWVISER0ZjdvWmtxdkI4ZFhqUDcxL2c9PQ==
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: tf-ceph
namespace: default
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
cephfs:
monitors:
- 10.10.10.204:6789
- 10.10.10.205:6789
- 10.10.10.206:6789
user: admin
path: /exports
secretRef:
name: ceph-secret
readOnly: false
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: tf-ceph
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi 开始创建名为 tf-ceph 的 PersistentVolume 和 PersistentVolumeClaim # 创建 ceph-pvc
kubectl create -f ceph-pvc.yaml
# 查看持久卷状态
kubectl get pv,pvc 使用持久卷创建 load_data.yaml 文件 apiVersion: batch/v1
kind: Job
metadata:
name: load-data
spec:
template:
metadata:
name: load-data
spec:
restartPolicy: Never
containers:
- name: loader
image: gcr.io/google-samples/tf-workshop:v2
command:
- "/bin/sh"
- "-c"
args:
- "curl https://storage.googleapis.com/oscon-tf-workshop-materials/processed_reddit_data/news_aww/prepared_data.tar.gz | tar xzv -C /var/tensorflow/"
volumeMounts:
- name: tf-ceph
mountPath: /var/tensorflow
volumes:
- name: tf-ceph
persistentVolumeClaim:
claimName: tf-ceph 执行 load_data.yaml 任务 kubectl create -f load_data.yaml
# 查看任务状态, 是否有报错, 直到正常运行
kubectl describe pod load-data 通过上面的流程跑通了使用 cephfs 创建 PersistentVolume 和 PersistentVolumeClaim, 并能正确导入数据, 完成了 ceph 和 k8s 结合. tensorflow 或其他的 pod 只需要加入下面配置块, 就能正常挂载 ceph 了.
volumeMounts:
- name: tf-ceph
mountPath: /var/tensorflow
volumes:
- name: tf-ceph
persistentVolumeClaim:
claimName: tf-ceph |
@vienlee 测试开启 Cephx 认证的 Ceph 与 k8s 结合,测试通过。 |
@ali8zake it was deleted by the author, which only can be visited from history commit now: |
k8s 运行分布式 tensorflow 实验
实验基于 @wangkuiyi 给出的 GitHub 地址 https://github.com/amygdala/tensorflow-workshop/tree/master/workshop_sections/distributed_tensorflow
我们目标需要在 k8s 上运行 tensorflow + ceph, 先通过这个实验流程来熟悉 tensorflow 在 k8s 上可行性和流程, 后续使用 ceph 存储来代替 NFS. 下面会记录实验流程和注意事项.
准备工作
Step1: 运行 nfs_server 在 k8s 上
项目文档中需要我们先创建一个 GCE Persistent Disk, 这里我们使用 k8s 集群的 Node 空间作为 NFS Server 的磁盘
Step2: 创建 nfs-pvc(PersistentVolumeClaim)
持久卷(PersistentVolumeClaim)持久化的存储(诸如
gcePersistent
或iscsi
卷)而且还无须知道特定云环境的细节,在pod中使用persistentVolumeClaim
就可以挂载。关于PersistentVolumeClaim的细节https://github.com/kubernetes/kubernetes/blob/release-1.0/docs/user-guide/persistent-volumes.md
创建 nfs 的持久卷
注意: 使用 NFS, 需要为集群中 Node 装上 nfs client, 如果是 coreos , 打开 rpc-statd.service 服务即可.
Step3: 执行导入数据 Job
按部就班, 确保前面的流程都没有问题
Step4: 创建 Tensorboard Server
Step5: 启动 Tensorflow Job
任务会拉取
gcr.io/google-samples/tf-worker-example:latest
这个镜像(740MB), 每个 Node 都会拉取, 速度很慢会导致任务失败.这边解决方法是上传到 163 的 docker hub 上, 得到
hub.c.163.com/vienlee/tf-worker-example:latest
, 替换 tf-cluster.yaml 中的gcr.io/google-samples/tf-worker-example:latest
地址为hub.c.163.com/vienlee/tf-worker-example:latest
即可.之所以没有用私有仓库, 因为当前没有搭建可用的私有仓库, 而且还需要支持 https(否则需要修改每个 Node 的 docker 配置增加私有仓库地址)
等待所有 Pod 创建成功, 状态为 Runing.
总结
通过实验证明 tensorflow 可以正常在 k8s 上运行, 后续流程我们可以提前创建 pv(使用 cephfs 存储) 和 pvc, 把训练数据导入到 pv 中. 然后编译我们自己的任务镜像, 编排 tf-cluster.yaml 执行任务.
The text was updated successfully, but these errors were encountered: