Creating a deployment with attached GPU resources

Learn how to create a container with attached GPU resources.

IBM Cloud Private offers built-in GPU support for the images in the nvidia-docker Opens in a new tab project. To specify GPU resources, your deployments must specify images from the nvidia-docker project.

Two formats are available for you to create a deployment from the management console.

You can create deployments either by entering the parameter values in the Create Deployment window or by pasting a YAML file into the "Create resource" window.

Required user type or access level: Cluster administrator or team administrator

Before you begin, ensure that the nodes are ready for deployment. For more information, see Configuring a GPU worker node.

Known issues and limitations

IBM® Z (s390x) node does not support GPU.

If you run IBM Cloud Private in a mixed environment that has Linux® (x86_64), Linux® on Power® (ppc64le), and IBM® Z(s390x) nodes, nvidia-device-plugin DaemonSet only runs on Linux® (x86_64) and Linux® on Power® (ppc64le) cluster nodes.

Creating a deployment with GPU resources attached by using the Create Deployment window

  1. From the navigation menu, click Workloads > Deployments > Create Deployment.
  2. From the Container settings tab, specify the number of GPU requested for the deployment. Ensure that this value is a positive integer.
  3. Enter all the other parameters options that are needed for your deployment.
  4. Click Create.

Creating a deployment by using the "Create resource" window

  1. Create a gpu-demo.yaml file. This sample gpu-demo.yaml file creates a container deployment with a single attached GPU resource.

    This sample deployment uses the nvidia/cuda:7.5-runtime image, which is a nvidia-docker image for Linux® systems. You can obtain this image from the nvidia/cuda Opens in a new tab Docker Hub repository. For Power Systems, use one of the nvidia/cuda-ppc64le images that are available in the nvidia/cuda-ppc64le Opens in a new tab Docker Hub repository.

    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
     name: gpu-demo
    spec:
     replicas: 1
     selector:
       matchLabels:
         run: gpu-demo
     template:
       metadata:
         labels:
           run: gpu-demo
       spec:
         containers:
         - name: gpu-demo
           image: nvidia/cuda:7.5-runtime
           command:
           - "/bin/sh"
           - "-c"
           args:
           - nvidia-smi && tail -f /dev/null
           resources:
             limits:
               nvidia.com/gpu: 1
    
  1. From the dashboard, click Create resource.
  2. Copy and paste the gpu-demo.yaml file into the "Create resource" dialog box.
  3. Click Create.

Check whether the GPU resource is detected inside the container

  1. Install the kubectl command line interface. See Accessing your cluster from the Kubernetes CLI (kubectl).

  2. To view a list of running containers, run this command:

    kubectl get pods
    

    From the returned output, you can locate the gpu-demo deployment.

  3. Access the logs for the gpu-demo deployment. For example,

    kubectl logs gpu-demo-3638364752-zkqel
    

    The output resembles the following code:

    Tue Feb  7 08:38:11 2017
    +------------------------------------------------------+
    | NVIDIA-SMI 352.63     Driver Version: 352.63         |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |===============================+======================+======================|
    |   0  GeForce GT 730      Off  | 0000:01:00.0     N/A |                  N/A |
    | 36%   41C    P8    N/A /  N/A |      4MiB /  1023MiB |     N/A      Default |
    +-------------------------------+----------------------+----------------------+
    
    +-----------------------------------------------------------------------------+
    | Processes:                                                       GPU Memory |
    |  GPU       PID  Type  Process name                               Usage      |
    |=============================================================================|
    |    0                  Not Supported                                         |
    +-----------------------------------------------------------------------------+
    

After the deployment completes, a new deployment is displayed on the Deployments page. The DESIRED, CURRENT, READY, and AVAILABLE columns all display the same value, which is the number of pods or replica that you specified during the deployment.

Click the deployment name to view detailed information about the deployment. Review the deployment properties and ensure that they are accurate.

To access your deployment from the Internet, you must expose your deployment as a service. See Creating services.