GPU Enablement

Open Data Hub has support for accessing NVIDIA GPUs from Jupyter notebooks. Currently, the Open Data Hub team has verified that JupyterHub can successfully access the GPU in OpenShift 3.11 clusters. OpenShift 4.x GPU enablement is still in development. These instructions will be updated as soon as it is available.


  • OpenShift cluster with GPU(s) enabled
    • Enabling GPUs in OpenShift 3.11 is outside of the scope of Open Data Hub. The document How to use GPUs with DevicePlugin in OpenShift 3.11 can provide guidance, but is not official.
    • Enabling GPUs in OpenShift 4.x can be achieved by deploying Node Feature Discovery (NFD) Operator and NVIDIA GPU Operator.

      The Node Feature Discovery operator is responsible for discovering and labeling hardware (GPU(s) in this case) features available on each node. The NVIDIA GPU Operator will setup and install the necessary drivers to enable the use of GPU(s) as compute resource.

      1. Deploy the Node Feature Discovery operator using the OpenShift OperatorHub WebUI. The blog on Creating a GPU-enabled node with OpenShift 4.2 in Amazon EC2 has a “Deploy the Node Feature Discovery Operator” section that demonstrates how to deploy the NFD operator and create a NodeFeatureDiscovery custom resource

      2. Before deploying the NVIDIA GPU Operator confirm that all of the nodes with GPUs have the appropriate hardware labels.
        $ oc describe node <GPU NODE NAME> -o json 
         Name:    ip-10-0-137-200.ec2.internal
         Roles:   worker
      3. Deploy the NVIDIA GPU operator using the OpenShift OperatorHub WebUI. The guide OpenShift on GPU install has a GPU support section covering all the steps to deploy the NVIDIA GPU operator.

      4. Once the Special Resource Operator finishes the installation of the appropriate drivers, you should see the number of gpus available as a resource on the GPU enabled nodes.

        $ oc get node <GPU NODE NAME> -o json | jq .status.allocatable
           "cpu": "3500m",
           "hugepages-1Gi": "0",
           "hugepages-2Mi": "0",
           "memory": "15804984Ki",
           "pods": "250",
           "": "1"

Configuring the JupyterHub component

To properly configure the aicoe-jupytherhub component to use GPUs, 2 things must be done

  1. Deploy GPU Compatible Jupyter Notebook Images by setting notebook_images.deploy_cuda_notebooks: True.
  2. Configure JupyterHub Server to spawn user pods with GPU access by setting gpu_mode to empty/null, selinux, or privileged

These settings will deploy a set of BuildConfigs which prepare CUDA enabled Python s2i images which are then used for building s2i-tensorflow-notebook-gpu image available in JupyterHub Spawner UI. This image has Tensorflow GPU pre-installed and enables users to leverage GPUs available in a cluster with the Tensorflow library.

The build chain template can be found upstream at

OpenShift 4.x

Leave the gpu_mode empty or set it to null.

    gpu_mode: ""
        deploy_cuda_notebooks: True

OpenShift 3.11 (Standard)

If the configuration of the cluster is based on the documentation How to use GPUs with DevicePlugin in OpenShift 3.11, set gpu_mode to value selinux

    gpu_mode: "selinux"
        deploy_cuda_notebooks: True

OpenShift 3.11 (Other)

In the case GPU enablement in the cluster is configured differently, containers may be required to run in privileged mode to gain access to GPUs. In this case set gpu_mode to value privileged

    gpu_mode: "privileged"
        deploy_cuda_notebooks: True

Verifying GPU Availability

To spawn a Jupyter Notebook with GPU support, set the GPU field to a number greater than 0. From inside the notebook, run the following command to verify it’s availability.

import tensorflow as tf

Additional resources