Skip To Content

Configure ArcGIS Notebook Server to use GPUs

The use of graphical processing units (GPUs) rapidly improves the processing time for machine learning models. ArcGIS Notebook Server can take advantage of NVIDIA GPUs on its host machine once some additional steps are performed.

Once ArcGIS Notebook Server has been installed and configured, follow these steps using the same machine.

  1. Install the appropriate NVIDIA drivers on the machine. See the NVIDIA website for complete information.
  2. Install the nvidia-docker 2.0 runtime on the machine so that notebook containers can take advantage of GPUs. Refer to the NVIDIA-Docker repository on GitHub for the downloads and documentation pertaining to your specific OS.
  3. Run the following command to ensure your NVIDIA elements are properly installed:

    docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

  4. Extend the existing notebook runtime in a Dockerfile to set the following environment variables, enabling NVIDIA Container Runtime for GPU-accelerated containers.

    # Specify the existing notebook runtime imageId as FROM
    FROM <imageID>
    
    # Use RUN to issue a command to install
    # Declare environment variables with ENV
    #RUN conda install <your_preferred_gpu_package>
    ENV NVIDIA_VISIBLE_DEVICES all
    ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
    ENV NVIDIA_REQUIRE_CUDA "cuda>=9.2"

    You may also decide to install other Python modules that can take advantage of GPU support. Follow the steps in Extend a notebook runtime to build a Dockerfile.

    Follow these steps to check the imageId of an existing notebook runtime. Sign in to the ArcGIS Notebook Server Administrator Directory at https://notebookserver.domain.com:11443/arcgis/admin and navigate to notebooks > runtimes", select the runtime you will use as the base of the GPU-enabled runtime, and check for the Image ID property.

    1. Sign in to the ArcGIS Notebook Server Administrator Directory at https://notebookserver.domain.com:11443/arcgis/admin.
    2. Click notebooks > runtimes.
    3. Select the runtime you will use as the base of the GPU-enabled runtime and check for the Image ID property.
  5. Build your custom container image using the following command syntax:

    docker build -t myGpuRuntime:v1.0 -f <path_to_Dockerfile> .
    Ensure you include the period at the end of the command.

    When the image build is complete, an output message will deliver the abridged imageId of the new image.

  6. Get the full imageId of your new container.

    docker inspect <imageId>

  7. Sign in to the ArcGIS Notebook Server Administrator Directory at https://notebookserver.domain.com:11443/arcgis/admin. Browse to notebooks > runtimes, and select the runtime you chose in Step 4, and click edit.
  8. Update the runtime to use your new custom image. Replace the existing imageId value with the value for your image, which you obtained in step 6.
  9. Set the dockerRuntime value to nvidia. Save your edits.
  10. Verify you have successfully configured ArcGIS Notebook Server to use NVIDIA GPUs. As a portal member with the Create and edit notebooks privilege or the Advanced Notebooks privilege if you chose the advanced runtime in step 4, open a new notebook. Copy the following into a cell and run the cell.

    import torch
    torch.cuda.is_available()
    The output should return as True, because the torch.cuda package requires GPUs to run.

  11. Run the following command in a new cell to view your machine's GPU configuration:

    !nvidia-smi

To remove the capacity for your ArcGIS Notebook Server site to use GPUs, run the Restore Factory Runtimes operation in the Administrator Directory. This is available at the URL https://notebookserver.domain.com:11443/arcgis/admin/notebooks/runtimes/restore.