Configure a Jupyter notebook to use GPUs for AI/ML modeling

For the best experience in this learning path, we suggest that you complete the following learning resources in the order shown. When you click on a resource, it will open in a new tab. Keep this page open so you can easily move on to the next resource!

Overview: Configure a Jupyter notebook to use GPUs for AI/ML modeling

Prepare your Jupyter notebook server for using a GPU

Red Hat OpenShift Data Science is a managed cloud service for data scientists and developers of artificial intelligence (AI) applications. It provides a fully supported environment in which to rapidly develop, train, and test machine learning models in the public cloud before deploying them in production. OpenShift Data Science can be hosted in Red Hat OpenShift Dedicated or Red Hat OpenShift Service on AWS, which simplifies cloud operations for the developer.

In this learning path, you will walk through configuring a Jupyter notebook to use GPUs for AI/ML modeling. You will learn how to use PyTorch to examine GPU resources, then load and run a PyTorch model.

Start your Jupyter notebook server

Let's start by setting up options for your Jupyter notebook server.  If you can’t remember how to launch JupyterHub, go back to the Launch JupyterHub learning path.

Select options for your notebook server

When you first gain access to JupyterHub, a configuration screen (Figure 1) gives you the opportunity to select a notebook image and configure its options, including the number of GPUs. You can customize the following options:

  • Notebook image
  • Deployment size
  • Number of GPUs
  • Environment variables
Figure 1: JupyterHub offers several options for creating and running a notebook.
Figure 1: JupyterHub offers several options for creating and running a notebook.

 

The following subsections list which prerequisites you need to choose for this activity.

Notebook image

You can choose from a number of predefined images. The JupyterLab instance that is created based on your choice has the associated libraries and packages that you need to do your work.

Available notebook images include:

  • Minimal Python
  • Standard Data Science
  • CUDA
  • PyTorch
  • Tensorflow

For this learning path, choose the PyTorch notebook image. 

Deployment size

You can choose different deployment sizes based on the type of data analysis and machine learning code you are working on.  Each deployment size is pre-configured with specific CPU and memory resources.

For this learning path, select the Small deployment size. 

Number of GPUs

Depending on the GPU Machine pool added to your cluster, you may be able to select one or more GPUs.  For this learning path, you need one GPU.

Environment variables

The environment variables section is useful for injecting dynamic information that you don't want to save in your notebook. This learning path does not use any environment variables. 

If you are satisfied with your notebook server selections, click the Start Server button to start the notebook server. 

A dialogue box saying Starting Server will appear.  After the Success message appears (Figure 2), you will shortly be transferred to your JupyterLab instance.

Figure 2:Once the notebook server has started, JupyterLab will automatically open and you will be ready to experiment.
Figure 2:Once the notebook server has started, JupyterLab will automatically open and you will be ready to experiment.

 

If this procedure is successful, you have started your Jupyter notebook server.