本文通过运行TensorFlow的GPU实验环境为您介绍支持GPU调度的Kubernetes GPU集群。
运行TensorFlow的GPU实验环境
数据科学家通常习惯使用Jupyter作为TensorFlow实验环境,本文用一个例子向您展示如何快速部署一个Jupyter应用。
本文通过运行TensorFlow的GPU实验环境为您介绍支持GPU调度的Kubernetes GPU集群。
数据科学家通常习惯使用Jupyter作为TensorFlow实验环境,本文用一个例子向您展示如何快速部署一个Jupyter应用。
本例中,示例模板是一个Jupyter应用,包括一个Deployment和Service。
---
# Define the tensorflow deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: tf-notebook
labels:
app: tf-notebook
spec:
replicas: 1
selector: # define how the deployment finds the pods it mangages
matchLabels:
app: tf-notebook
template: # define the pods specifications
metadata:
labels:
app: tf-notebook
spec:
containers:
- name: tf-notebook
image: tensorflow/tensorflow:1.4.1-gpu-py3
resources:
limits:
nvidia.com/gpu: 1 #指定调用nvidia gpu的数量
ports:
- containerPort: 8888
hostPort: 8888
env:
- name: PASSWORD # 指定访问Jupyter服务的密码,您可以按照您的需要修改
value: mypassword
# Define the tensorflow service
---
apiVersion: v1
kind: Service
metadata:
name: tf-notebook
spec:
ports:
- port: 80
targetPort: 8888
name: jupyter
selector:
app: tf-notebook
type: LoadBalancer #阿里云的负载均衡访问内部服务和负载均衡
旧的GPU部署方案,您必须要定义以下的nvidia驱动所在的数据卷。
volumes:
- hostPath:
path: /usr/lib/nvidia-375/bin
name: bin
- hostPath:
path: /usr/lib/nvidia-375
name: lib
这需要您在编写部署文件时,强依赖于所在的集群,导致缺乏可移植性。但是在Kubernetes 1.9.3及之后的版本中,无需指定hostPath,nvidia的插件会自发现驱动所需的库链接和执行文件。
http://外部端点
,输入模板中配置的密码。from tensorflow.python.client import device_lib
def get_available_devices():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos]
print(get_available_devices())
在文档使用中是否遇到以下问题
更多建议
匿名提交