Jump to content

GPU acceleration in Spark

From Open Lakehouse Wiki
GPU acceleration in Spark
Also known as GPU-accelerated Spark, Spark on GPUs
Field Distributed data processing
Introduced Apache Spark 3.0 (accelerator-aware scheduling)
Key parts GPU resource scheduling, SQL plugins, GPU machine learning libraries
Open source implementations Apache Spark, NVIDIA cuDF plugin for Apache Spark (formerly RAPIDS Accelerator), Apache Gluten, cuML Spark
Related Spark resource profiles, Native execution engine (Spark), Velox
Last verified 23 November 2026 against the v4.3.0 tag of apache/spark (docs/configuration.md, python/pyspark/ml/torch/distributor.py), the NVIDIA cuDF plugin for Apache Spark download, configuration, supported operators, FAQ and getting-started pages and its v26.10.0 GitHub release, the apache/gluten README and VeloxGPU.md on the main branch, and the NVIDIA/cuml-spark repository.

GPU acceleration in Spark is the use of graphics processing units (GPUs) to run parts of an Apache Spark application, either by scheduling GPUs to tasks that use them directly (for example deep learning training) or by replacing Spark SQL operators with GPU implementations. Apache Spark itself provides the first part: since Spark 3.0, its scheduler can request GPUs for executors and assign GPU addresses to tasks.[1][2] Running Spark SQL and DataFrame operators on a GPU needs a plugin such as the NVIDIA cuDF plugin for Apache Spark, formerly called the RAPIDS Accelerator for Apache Spark.[3]

Comparison of GPU options for Spark

Apache Spark GPU scheduling NVIDIA cuDF plugin for Apache Spark Apache Gluten with Velox cuDF cuML Spark
What runs on the GPU User code that reads the GPU addresses Spark assigns (RDD functions, pandas UDFs, ML training)[2] Supported Spark SQL and DataFrame operators, file scans and writes[4] Velox plan nodes converted to cuDF operators[5] PySpark ML algorithms backed by the cuML library[6]
How it is enabled spark.executor.resource.gpu.amount, spark.task.resource.gpu.amount, a discovery script, or a resource profile[2] spark.plugins=com.nvidia.spark.SQLPlugin plus the rapids-4-spark jar[7][3] spark.gluten.sql.columnar.cudf=true in a GPU build of Gluten[5] Change the import, for example spark_rapids_ml.feature.PCA in place of pyspark.ml.feature.PCA[6]
Unsupported work Not applicable; Spark does not use the GPU itself[2] Falls back to the Spark CPU implementation; RDD operations are not accelerated[4] Falls back to CPU operators, with row and columnar conversion[5] Algorithms not in its list are not provided[6]
Status Part of Apache Spark since 3.0.0[1] Release v26.10.0, published 2026-11-05[8] Experimental; documented on the main branch, not in the v1.7.0 release[5] Release v26.06.0, published 2026-07-22[9]
Spark versions 3.0.0 and later[1] 3.3.0 to 4.2.0 in release v26.10.0; 4.3.0 is not listed[3] Same as Gluten on CPU[5] Not stated in the README
License Apache License 2.0[10] Source code Apache 2.0; documentation CC BY 4.0[11] Apache License 2.0[12] Apache License 2.0[6]

How does Apache Spark schedule GPUs?

Apache Spark schedules GPUs as a custom resource named gpu. An application sets spark.executor.resource.gpu.amount (default 0) for GPUs per executor and spark.task.resource.gpu.amount for GPUs per task; fractional task amounts let several tasks share one GPU. On YARN and Kubernetes, the executor also needs spark.executor.resource.gpu.discoveryScript, and Kubernetes needs spark.executor.resource.gpu.vendor, for example nvidia.com.[2] Spark then assigns GPU addresses to each task, which user code reads with TaskContext.get().resources().[2] Since Spark 3.1, Spark resource profiles let one stage request GPU executors while other stages use CPU-only executors.[2]

Spark's own GPU support is used by machine learning code inside Spark. pyspark.ml.torch.distributor.TorchDistributor, added in Spark 3.4.0, runs distributed PyTorch training on Spark; with use_gpu=True (the default) on a cluster it requires spark.task.resource.gpu.amount of at least 1.[13]

What is the NVIDIA cuDF plugin for Apache Spark?

The NVIDIA cuDF plugin for Apache Spark is a set of Spark plugins, built on the cuDF library and UCX, that run DataFrame and SQL processing on NVIDIA GPUs. NVIDIA renamed it from the RAPIDS Accelerator for Apache Spark; the GitHub repository moved from NVIDIA/spark-rapids to NVIDIA/cudf-spark, and the artifact name rapids-4-spark stays the same for now.[3][14] The plugin hooks into Spark at the Catalyst level, after the language APIs have been converted to a DataFrame plan, so it applies to PySpark, Scala, Java and SQL alike.[15]

The cuDF plugin is turned on with spark.plugins=com.nvidia.spark.SQLPlugin. NVIDIA's on-premise example combines it with Spark's own GPU settings, spark.executor.resource.gpu.amount=1 and spark.task.resource.gpu.amount=0.25.[7] The getting-started guide asks for Apache Spark 3.3 or later and one GPU per executor.[4]

spark-submit \
  --jars rapids-4-spark_2.13-26.10.0.jar \
  --conf spark.plugins=com.nvidia.spark.SQLPlugin \
  --conf spark.executor.resource.gpu.amount=1 \
  --conf spark.task.resource.gpu.amount=0.25 \
  --conf spark.rapids.sql.explain=NOT_ON_GPU \
  app.py

Which operators and formats run on the GPU?

The cuDF plugin replaces physical operators such as FileSourceScanExec, FilterExec, ProjectExec, HashAggregateExec, SortExec, WindowExec, ShuffleExchangeExec, BroadcastHashJoinExec, ShuffledHashJoinExec and SortMergeJoinExec, and pandas UDF operators such as MapInPandasExec.[16] Its supported-operators page lists GPU reads for Avro, CSV, Delta Lake, Hive text, Apache Iceberg, JSON, ORC and Apache Parquet, and GPU writes for Delta Lake, Hive text, Iceberg, ORC and Parquet. Timestamps are supported only in the UTC time zone.[16]

The cuDF plugin's FAQ states that only a limited set of SQL and DataFrame operations is supported; some MLlib functions such as PCA are accelerated, while GraphX and RDD code are not. Dataset operations that take Scala or Java functions, such as flatMap or foreachPartition, still run correctly but mostly on the CPU.[15]

What happens when an operator is not supported?

When the cuDF plugin cannot run an operation on the GPU, that part of the plan runs on the Spark CPU implementation, so the query still completes.[4] The plugin decides this with rules, not the Spark scheduler.[15] spark.rapids.sql.enabled (default true) turns GPU SQL on or off, and spark.rapids.sql.explain logs the parts of a plan that were not placed on the GPU, for example with the value NOT_ON_GPU.[17]

What other GPU options exist for Spark?

Apache Gluten, a project that offloads Spark SQL execution to native engines such as Velox, documents an experimental GPU path on its main branch: with spark.gluten.sql.columnar.cudf=true, Velox plan nodes are converted to GPU operators built on cuDF, and unsupported operators fall back to the CPU.[5] See Native execution engine (Spark) for CPU-based native engines.

cuML Spark (repository NVIDIA/cuml-spark) provides PySpark ML compatible algorithms on GPUs, including KMeans, LinearRegression, LogisticRegression, PCA, RandomForestClassifier and UMAP.[6]

See also

References

  1. ↑ 1.0 1.1 1.2 Spark Release 3.0.0. Apache Software Foundation.Retrieved 2026-11-23.
  2. ↑ 2.0 2.1 2.2 2.3 2.4 2.5 2.6 Spark Configuration (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
  3. ↑ 3.0 3.1 3.2 3.3 Download (NVIDIA cuDF plugin for Apache Spark). NVIDIA.Retrieved 2026-11-23.
  4. ↑ 4.0 4.1 4.2 4.3 Getting started overview (cuDF plugin for Apache Spark User Guide). NVIDIA.Retrieved 2026-11-23.
  5. ↑ 5.0 5.1 5.2 5.3 5.4 5.5 GPU Acceleration in Velox/Gluten (VeloxGPU.md, main branch). Apache Software Foundation.Retrieved 2026-11-23.
  6. ↑ 6.0 6.1 6.2 6.3 6.4 NVIDIA/cuml-spark. GitHub.Retrieved 2026-11-23.
  7. ↑ 7.0 7.1 Getting started on-prem (cuDF plugin for Apache Spark User Guide). NVIDIA.Retrieved 2026-11-23.
  8. ↑ v26.10.0 release. GitHub.Retrieved 2026-11-23.
  9. ↑ Releases, NVIDIA/cuml-spark. GitHub.Retrieved 2026-11-23.
  10. ↑ LICENSE (apache/spark v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
  11. ↑ LICENSE, NVIDIA/cudf-spark. GitHub.Retrieved 2026-11-23.
  12. ↑ Apache Gluten README. Apache Software Foundation.Retrieved 2026-11-23.
  13. ↑ pyspark/ml/torch/distributor.py (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
  14. ↑ NVIDIA cuDF plugin for Apache Spark README. GitHub.Retrieved 2026-11-23.
  15. ↑ 15.0 15.1 15.2 Frequently Asked Questions (cuDF plugin for Apache Spark User Guide). NVIDIA.Retrieved 2026-11-23.
  16. ↑ 16.0 16.1 Supported Operators (NVIDIA cuDF plugin for Apache Spark). NVIDIA.Retrieved 2026-11-23.
  17. ↑ Configuration (NVIDIA cuDF plugin for Apache Spark). NVIDIA.Retrieved 2026-11-23.