【问题标题】:How to run data science model's docker image on Azure Kubernetes Services (GPU enabled)如何在 Azure Kubernetes 服务(启用 GPU)上运行数据科学模型的 docker 映像
【发布时间】:2020-01-09 04:56:26
【问题描述】:

如何在 Azure Kubernetes 服务(启用 GPU)上运行数据科学模型的 docker 映像,以便它可以利用 Kubernetes 集群的 GPU 功能。我们用来构建模型的包有tensorflow、keras、scikit-learn等,是否需要在Dockerfile中包含Cuda安装步骤?

还发现下面的错误:

【问题讨论】:

    标签: python docker kubernetes data-science azure-aks


    【解决方案1】:
    1. 创建具有支持 gpu 的 vm 大小的 aks
    2. 安装 nvidia 驱动程序
    3. 运行您的工作负载

    对于第 2 点,使用以下 yaml:

    apiVersion: extensions/v1beta1
    kind: DaemonSet
    metadata:
      name: nvidia-device-plugin-daemonset
      namespace: kube-system
    spec:
      updateStrategy:
        type: RollingUpdate
      template:
        metadata:
          # Mark this pod as a critical add-on; when enabled, the critical add-on scheduler
          # reserves resources for critical add-on pods so that they can be rescheduled after
          # a failure.  This annotation works in tandem with the toleration below.
          annotations:
            scheduler.alpha.kubernetes.io/critical-pod: ""
          labels:
            name: nvidia-device-plugin-ds
        spec:
          tolerations:
          # Allow this pod to be rescheduled while the node is in "critical add-ons only" mode.
          # This, along with the annotation above marks this pod as a critical add-on.
          - key: CriticalAddonsOnly
            operator: Exists
          - key: nvidia.com/gpu
            operator: Exists
            effect: NoSchedule
          containers:
          - image: nvidia/k8s-device-plugin:1.11
            name: nvidia-device-plugin-ctr
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                drop: ["ALL"]
            volumeMounts:
              - name: device-plugin
                mountPath: /var/lib/kubelet/device-plugins
          volumes:
            - name: device-plugin
              hostPath:
                path: /var/lib/kubelet/device-plugins
    

    关于这个问题的官方文档。你也可以使用these official k8s docs on using GPU。我认为您应该只使用包含 GPU 驱动程序的基础映像,例如,您可以使用 MS 提供的示例映像作为基础,或类似 tensorflow/tensorflow:latest-gpu 的东西。

    【讨论】:

    • 嗨..我已经完成了上述步骤。现在在我的 dockerfile 中,我使用“python 3.6”作为基本映像,然后运行我的模型 ysing python 命令。这行得通吗?
    • 可能不是,您的映像中需要 gpu 驱动程序,如答案所示
    • 嗨,我已经在我的镜像中使用了一个 gpu 驱动程序。我已经在我的问题中更新了 Dockerfile。同时粘贴了我遇到的错误
    猜你喜欢
    • 2015-11-20
    • 2019-10-31
    • 1970-01-01
    • 2020-06-27
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多