---
title: GPU-enabled compute
description: Learn about GPU-enabled Databricks compute, when to use them, what they require, and how to create them.
canonical_url: https://docs.databricks.com/gcp/en/compute/gpu
---

# GPU-enabled compute

> [!NOTE]
>
> Some GPU-enabled instance types are in **Beta** and are marked as such in the drop-down list when you select the driver and worker types during compute creation.

## Overview

Databricks supports compute accelerated with graphics processing units (GPUs).
This article describes how to create compute with GPU-enabled instances and describes
the GPU drivers and libraries installed on those instances.

To learn more about deep learning on GPU-enabled compute, see [Deep learning](https://docs.databricks.com/gcp/en/machine-learning/train-model/deep-learning.md).

## Create a GPU compute

Creating a GPU compute is similar to creating any compute. Keep in mind the following:

* The **Machine learning** checkbox must be checked. The GPU ML version is chosen automatically based on the worker type.
* The **Photon acceleration** checkbox must be unchecked. Photon is not supported with GPU instance types.
* The **Worker type** must be a GPU instance type.
* The **Single node** checkbox can be checked to get a single GPU instance.

The process for configuring GPU instances using the [Clusters API](https://docs.databricks.com/api/workspace/clusters/create) varies depending on whether the `kind` field is set. `kind` determines whether your request uses the [simple form](https://docs.databricks.com/gcp/en/compute/simple-form.md) specification:

* If `kind = CLASSIC_PREVIEW`, set `"use_ml_runtime": true`.
* If you don't set the `kind` field, set `spark_version` to a GPU-enabled version, such as **15.4.x-gpu-ml-scala2.12**.

### <a id="gpu-list" />Supported instance types

Databricks supports the following instance types:

#### A3 High

* GPU Type: NVIDIA H100 80GB GPU

| Instance Name     | Number of GPUs | GPU Memory | vCPUs | CPU Memory |
| ----------------- | -------------- | ---------- | ----- | ---------- |
| **a3-highgpu-8g** | 8              | 80GB x 8   | 208   | 1872GB     |

#### A2 Ultra

* GPU Type: NVIDIA A100 80GB GPU

| Instance Name      | Number of GPUs | GPU Memory | vCPUs | CPU Memory |
| ------------------ | -------------- | ---------- | ----- | ---------- |
| **a2-ultragpu-1g** | 1              | 80GB       | 12    | 170GB      |
| **a2-ultragpu-2g** | 2              | 80GB x 2   | 24    | 340GB      |
| **a2-ultragpu-4g** | 4              | 80GB x 4   | 48    | 680GB      |
| **a2-ultragpu-8g** | 8              | 80GB x 8   | 96    | 1360GB     |

#### A2 Standard

* GPU Type: NVIDIA A100 40GB GPU

| Instance Name      | Number of GPUs | GPU Memory | vCPUs | CPU Memory |
| ------------------ | -------------- | ---------- | ----- | ---------- |
| **a2-highgpu-1g**  | 1              | 40GB       | 12    | 85GB       |
| **a2-highgpu-2g**  | 2              | 40GB x 2   | 24    | 170GB      |
| **a2-highgpu-4g**  | 4              | 40GB x 4   | 48    | 340GB      |
| **a2-highgpu-8g**  | 8              | 40GB x 8   | 96    | 680GB      |
| **a2-megagpu-16g** | 16             | 40GB x 16  | 96    | 1360GB     |

#### G2

* GPU Type: NVIDIA L4 GPU

| Instance Name      | Number of GPUs | GPU Memory | vCPUs | CPU Memory |
| ------------------ | -------------- | ---------- | ----- | ---------- |
| **g2-standard-4**  | 1              | 24GB       | 4     | 16GB       |
| **g2-standard-8**  | 1              | 24GB       | 8     | 32GB       |
| **g2-standard-12** | 1              | 24GB       | 12    | 48GB       |
| **g2-standard-16** | 1              | 24GB       | 16    | 64GB       |
| **g2-standard-24** | 2              | 24GB x 2   | 24    | 96GB       |
| **g2-standard-32** | 1              | 24GB       | 32    | 128GB      |
| **g2-standard-48** | 4              | 24GB x 4   | 44    | 192GB      |
| **g2-standard-96** | 8              | 24GB x 8   | 96    | 384GB      |

See [GCP accelerator-optimized machines](https://cloud.google.com/compute/docs/accelerator-optimized-machines)
for more information on these instance types, and [GCP regions](https://cloud.google.com/compute/docs/regions-zones) to check where these instances are available. Your Databricks deployment must reside in a supported region to launch GPU-enabled compute.

## <a id="gpu-scheduling" />GPU scheduling

GPU scheduling distributes Spark tasks efficiently across a large number of GPUs.

Databricks Runtime 9.1 LTS ML and above support GPU-aware scheduling from Apache Spark 3.0. Databricks preconfigures it on GPU compute for you.

> [!NOTE]
>
> GPU scheduling is not enabled on single-node compute.

### GPU scheduling for AI and ML

`spark.task.resource.gpu.amount` is the only Spark config related to GPU-aware scheduling that you may need to configure.
The default configuration uses one GPU per task, which is a good baseline for distributed inference workloads and distributed training if you use all GPU nodes.

To reduce communication overhead during distributed training, Databricks recommends setting `spark.task.resource.gpu.amount` to the number of GPUs per worker node in the compute [Spark configuration](https://docs.databricks.com/gcp/en/compute/configure.md#spark-configuration). This creates only one Spark task for each Spark worker and assigns all GPUs in that worker node to the same task.

To increase parallelization for distributed deep learning inference, you can set `spark.task.resource.gpu.amount` to fractional values such as 1/2, 1/3, 1/4, … 1/N. This creates more Spark tasks than there are GPUs, allowing more concurrent tasks to handle inference requests in parallel. For example, if you set `spark.task.resource.gpu.amount` to `0.5`, `0.33`, or `0.25`, then the available GPUs will be split among double, triple, or quadruple the number of tasks.

### GPU indices

For PySpark tasks, Databricks automatically remaps assigned GPU(s) to zero-based indices. For the default configuration that uses one GPU per task, you can use the default GPU without checking which GPU is assigned to the task.
If you set multiple GPUs per task, for example, 4, the indices of the assigned GPUs are always 0, 1, 2, and 3. If you do need the physical indices of the assigned GPUs, you can get them from the `CUDA_VISIBLE_DEVICES` environment variable.

If you use Scala, you can get the indices of the GPUs assigned to the task from `TaskContext.resources().get("gpu")`.

## <a id="nvidia" />NVIDIA GPU driver, CUDA, and cuDNN

Databricks installs the NVIDIA driver and libraries required to use GPUs on Spark driver and worker instances:

* [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit), installed under `/usr/local/cuda`.
* [cuDNN](https://developer.nvidia.com/cudnn): NVIDIA CUDA Deep Neural Network Library.
* [NCCL](https://developer.nvidia.com/nccl): NVIDIA Collective Communications Library.

The version of the NVIDIA driver included is 525.105.17, which supports CUDA 11.0.

For the versions of the libraries included, see the [release notes](https://docs.databricks.com/gcp/en/release-notes/runtime/index.md) for the specific Databricks Runtime version you are using.

> [!NOTE]
>
> This software contains source code provided by NVIDIA Corporation. Specifically, to support GPUs, Databricks includes code from [CUDA Samples](https://docs.nvidia.com/cuda/eula/#nvidia-cuda-samples-preface).

### NVIDIA End User License Agreement (EULA)

When you select a GPU-enabled “Databricks Runtime Version” in Databricks, you implicitly agree to the terms and conditions outlined in the
NVIDIA EULA with respect to the CUDA, cuDNN, and Tesla libraries,
and the [NVIDIA End User License Agreement (with NCCL Supplement)](https://docs.nvidia.com/deeplearning/sdk/nccl-sla/index.html#supplement/) for the NCCL library.

## <a id="databricks-container-services-on-gpu" />Databricks Container Services on GPU compute

> [!NOTE]
> **Preview**
>
> This feature is in [Public Preview](https://docs.databricks.com/gcp/en/release-notes/release-types.md).

You can use [Databricks Container Services](https://docs.databricks.com/gcp/en/compute/custom-containers.md) on compute with GPUs to create portable deep learning environments with customized libraries. See [Databricks Container Services for dedicated compute](https://docs.databricks.com/gcp/en/compute/custom-containers.md) for instructions.

To create custom images for GPU compute, you must select a standard runtime version instead of Databricks Runtime ML for GPU. When you select **Use your own Docker container**, you can choose GPU compute with a standard runtime version. The custom images for GPU are based on the [official CUDA containers](https://hub.docker.com/r/nvidia/cuda/), which is different from Databricks Runtime ML for GPU.

When you create custom images for GPU compute, you cannot change the NVIDIA driver version because it must match the driver version on the host machine.

The `databricksruntime` [Docker Hub](https://hub.docker.com/u/databricksruntime) contains example base images with GPU capability. The Dockerfiles used to generate these images are located in the [example containers GitHub repository](https://github.com/databricks/containers/tree/master/ubuntu/gpu), which also has details on what the example images provide and how to customize them.

## Limitations

* You cannot create a new GPU compute when you [schedule a job from a notebook](https://docs.databricks.com/gcp/en/notebooks/schedule-notebook-jobs.md). You can run a job on an existing GPU compute only if it was created in the [new compute UI](https://docs.databricks.com/gcp/en/compute/configure.md).
* With Databricks on Google Cloud, commonly used NVIDIA executables like `nvidia-smi` are not included in the `PATH` environment variable. Instead, they are in `/usr/local/nvidia/bin`. For example, to use `nvidia-smi` you must use either the [web terminal](https://docs.databricks.com/gcp/en/compute/web-terminal.md) or `%sh` [notebook magic commands](https://docs.databricks.com/gcp/en/notebooks/notebooks-code.md#language-magic) to run `/usr/local/nvidia/bin/nvidia-smi`.
* Monitoring compute metrics using Ganglia is not supported on Databricks on Google Cloud.
