Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ By making a contribution to this project, I certify that:
this project or the open source license(s) involved.
```

Note: This section `Sign your work` is derived from [https://github.com/NVIDIA/spark-rapids](https://github.com/NVIDIA/spark-rapids)
Note: This section `Sign your work` is derived from [https://github.com/NVIDIA/cudf-spark](https://github.com/NVIDIA/cudf-spark)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# spark-rapids-examples

This is the [RAPIDS Accelerator for Apache Spark](https://nvidia.github.io/spark-rapids/) examples repo.
RAPIDS Accelerator for Apache Spark accelerates Spark applications with no code changes.
You can download the latest version of RAPIDS Accelerator [here](https://nvidia.github.io/spark-rapids/docs/download.html).
This is the [NVIDIA cuDF plugin for Apache Spark](https://nvidia.github.io/cudf-spark/) examples repo.
The cuDF plugin accelerates Spark applications with no code changes.
You can download the latest version of the cuDF plugin [here](https://nvidia.github.io/cudf-spark/docs/download.html).
This repo contains examples and applications that showcases the performance and benefits of using
RAPIDS Accelerator in data processing and machine learning pipelines.
the cuDF plugin in data processing and machine learning pipelines.
There are broadly five categories of examples in this repo:
1. [SQL/Dataframe](./examples/SQL+DF-Examples)
2. [Spark XGBoost](./examples/XGBoost-Examples)
3. [Machine Learning/Deep Learning](./examples/ML+DL-Examples)
4. [RAPIDS UDF](./examples/UDF-Examples)
4. [cuDF plugin UDF](./examples/UDF-Examples)
5. [Databricks Tools demo notebooks](./tools/databricks)

For more information on each of the examples please look into respective categories.
Expand All @@ -29,7 +29,7 @@ Here is the list of notebooks in this repo:
| 9 | SQL/DF | [TPC-DS](https://www.tpc.org/tpcds/) Scale Factor 10 | Comparison of Spark SQL CPU vs GPU. Easy to run locally and on Google Colab

Here is the list of Apache Spark applications (Scala and PySpark) that
can be built for running on GPU with RAPIDS Accelerator in this repo:
can be built for running on GPU with the cuDF plugin in this repo:

| | Category | Notebook Name | Description
| ------------- | ------------- | ------------- | -------------
Expand Down
15 changes: 7 additions & 8 deletions docs/get-started/xgboost-examples/csp/databricks/databricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ The number of GPUs per node dictates the number of Spark executors that can run
Start A Databricks Cluster
--------------------------
Before creating the cluster, we will need to create an [initialization script](https://docs.databricks.com/clusters/init-scripts.html) for the
cluster to install the RAPIDS jars. Databricks recommends storing all cluster-scoped init scripts using workspace files.
cluster to install the NVIDIA cuDF plugin for Apache Spark jar. Databricks recommends storing all cluster-scoped init scripts using workspace files.
Each user has a Home directory configured under the /Users directory in the workspace.
Navigate to your home directory in the UI and select **Create** > **File** from the menu,
create an `init.sh` scripts with contents:
```bash
#!/bin/bash
sudo wget -O /databricks/jars/rapids-4-spark_2.12-26.06.0.jar https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.06.0/rapids-4-spark_2.12-26.06.0.jar
sudo wget -O /databricks/jars/rapids-4-spark_2.12-26.08.0.jar https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.08.0/rapids-4-spark_2.12-26.08.0.jar
```
1. Select the Databricks Runtime Version from one of the supported runtimes specified in the
Prerequisites section.
Expand All @@ -34,8 +34,7 @@ create an `init.sh` scripts with contents:
![Init Script](../../../../img/databricks/initscript.png)
6. Now select the “Spark” tab, and paste the following config options into the Spark Config section.
Change the config values based on the workers you choose. See Apache Spark
[configuration](https://spark.apache.org/docs/latest/configuration.html) and RAPIDS Accelerator
for Apache Spark [descriptions](https://nvidia.github.io/spark-rapids/docs/configs.html) for each config.
[configuration](https://spark.apache.org/docs/latest/configuration.html) and the cuDF plugin [configuration descriptions](https://nvidia.github.io/cudf-spark/docs/configs.html) for each config.

The
[`spark.task.resource.gpu.amount`](https://spark.apache.org/docs/latest/configuration.html#scheduling)
Expand All @@ -60,15 +59,15 @@ create an `init.sh` scripts with contents:
of python for Databricks. On Databricks, the python runtime requires different parameters than the
Spark one, so a dedicated python demon module `rapids.daemon_databricks` is created and should
be specified here. Set the config
[`spark.rapids.sql.python.gpu.enabled`](https://nvidia.github.io/spark-rapids/docs/configs.html#sql.python.gpu.enabled) to `true` to
[`spark.rapids.sql.python.gpu.enabled`](https://nvidia.github.io/cudf-spark/docs/configs.html#sql.python.gpu.enabled) to `true` to
enable GPU support for python. Add the path of the plugin jar (supposing it is placed under
`/databricks/jars/`) to the `spark.executorEnv.PYTHONPATH` option. For more details please go to
[GPU Scheduling For Pandas UDF](https://nvidia.github.io/spark-rapids/docs/additional-functionality/rapids-udfs.html#gpu-support-for-pandas-udf)
[GPU Scheduling For Pandas UDF](https://nvidia.github.io/cudf-spark/docs/additional-functionality/rapids-udfs.html#gpu-support-for-pandas-udf)

```bash
spark.rapids.sql.python.gpu.enabled true
spark.python.daemon.module rapids.daemon_databricks
spark.executorEnv.PYTHONPATH /databricks/jars/rapids-4-spark_2.12-26.06.0.jar:/databricks/spark/python
spark.executorEnv.PYTHONPATH /databricks/jars/rapids-4-spark_2.12-26.08.0.jar:/databricks/spark/python
```
Note that since python memory pool require installing the cudf library, so you need to install cudf library in
each worker nodes `pip install cudf-cu11 --extra-index-url=https://pypi.nvidia.com` or disable python memory pool
Expand Down Expand Up @@ -166,6 +165,6 @@ Limitations
4. Databricks makes changes to the runtime without notification.

Databricks makes changes to existing runtimes, applying patches, without notification.
[Issue-3098](https://github.com/NVIDIA/spark-rapids/issues/3098) is one example of this. We run
[Issue-3098](https://github.com/NVIDIA/cudf-spark/issues/3098) is one example of this. We run
regular integration tests on the Databricks environment to catch these issues and fix them once
detected.
2 changes: 1 addition & 1 deletion docs/get-started/xgboost-examples/csp/databricks/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
sudo rm -f /databricks/jars/spark--maven-trees--ml--10.x--xgboost-gpu--ml.dmlc--xgboost4j-gpu_2.12--ml.dmlc__xgboost4j-gpu_2.12__1.5.2.jar
sudo rm -f /databricks/jars/spark--maven-trees--ml--10.x--xgboost-gpu--ml.dmlc--xgboost4j-spark-gpu_2.12--ml.dmlc__xgboost4j-spark-gpu_2.12__1.5.2.jar

sudo wget -O /databricks/jars/rapids-4-spark_2.12-26.06.0.jar https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.06.0/rapids-4-spark_2.12-26.06.0.jar
sudo wget -O /databricks/jars/rapids-4-spark_2.12-26.08.0.jar https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.08.0/rapids-4-spark_2.12-26.08.0.jar
sudo wget -O /databricks/jars/xgboost4j-gpu_2.12-1.7.1.jar https://repo1.maven.org/maven2/ml/dmlc/xgboost4j-gpu_2.12/1.7.1/xgboost4j-gpu_2.12-1.7.1.jar
sudo wget -O /databricks/jars/xgboost4j-spark-gpu_2.12-1.7.1.jar https://repo1.maven.org/maven2/ml/dmlc/xgboost4j-spark-gpu_2.12/1.7.1/xgboost4j-spark-gpu_2.12-1.7.1.jar
ls -ltr
Expand Down
2 changes: 1 addition & 1 deletion docs/get-started/xgboost-examples/csp/dataproc/gcp.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Getting started pyspark+xgboost with RAPIDS Accelerator on GCP Dataproc
# Getting started with PySpark, XGBoost, and the NVIDIA cuDF plugin for Apache Spark on GCP Dataproc
[Google Cloud Dataproc](https://cloud.google.com/dataproc) is Google Cloud's fully managed Apache
Spark and Hadoop service. Please make sure to install gcloud CLI by following
this [guide](https://cloud.google.com/sdk/docs/install) before getting started.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ For simplicity export the location to these jars. All examples assume the packag

### Download the jars

Download the RAPIDS Accelerator for Apache Spark plugin jar
* [RAPIDS Spark Package](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.06.0/rapids-4-spark_2.12-26.06.0.jar)
Download the NVIDIA cuDF plugin for Apache Spark jar
* [cuDF plugin jar](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.08.0/rapids-4-spark_2.12-26.08.0.jar)

### Build XGBoost Python Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ For simplicity export the location to these jars. All examples assume the packag

### Download the jars

1. Download the RAPIDS Accelerator for Apache Spark plugin jar
* [RAPIDS Spark Package](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.06.0/rapids-4-spark_2.12-26.06.0.jar)
1. Download the NVIDIA cuDF plugin for Apache Spark jar
* [cuDF plugin jar](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.08.0/rapids-4-spark_2.12-26.08.0.jar)

### Build XGBoost Scala Examples

Expand Down
2 changes: 1 addition & 1 deletion examples/MIG-Support/device-plugins/gpu-mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ Note the getMIGGpus discovery script would is in the `scripts` directory in this
`nvidia/miggpu`.

## Testing
Run a Spark application using the [Rapids Accelerator for Apache Spark](https://nvidia.github.io/spark-rapids/) and request GPUs
Run a Spark application using the [NVIDIA cuDF plugin for Apache Spark](https://nvidia.github.io/cudf-spark/) and request GPUs
from YARN and verify they use the MIG enabled GPUs.
2 changes: 1 addition & 1 deletion examples/MIG-Support/resource-types/gpu-mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ Environment variable for Spark application:
```

## Testing
Run a Spark application using the [Rapids Accelerator for Apache Spark](https://nvidia.github.io/spark-rapids/) and request GPUs
Run a Spark application using the [NVIDIA cuDF plugin for Apache Spark](https://nvidia.github.io/cudf-spark/) and request GPUs
from YARN and verify they use the MIG enabled GPUs.
8 changes: 4 additions & 4 deletions examples/ML+DL-Examples/Optuna-Spark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ We provide **2 notebooks**, with differences in the backend/implementation. See
- `optuna-dataframe.ipynb`:
- Uses Spark dataframes to distribute tasks on the cluster.
- Implements *Spark-I/O*, where Spark reads the dataset from a specified filepath, then duplicates and repartitions it so that each worker task is mapped onto a copy of the dataset.
- Dataframe operations are accelerated on GPU with the [Spark-RAPIDS Accelerator](https://nvidia.github.io/spark-rapids/).
- Dataframe operations are accelerated on GPU with the [NVIDIA cuDF plugin for Apache Spark](https://nvidia.github.io/cudf-spark/).

## Running Optuna on Spark Standalone

Expand Down Expand Up @@ -147,8 +147,8 @@ We use [RAPIDS](https://docs.rapids.ai/install/#get-rapids) for GPU-accelerated
``` shell
sudo apt install libmysqlclient-dev

conda create -n rapids-26.06 -c rapidsai -c conda-forge -c nvidia \
cudf=26.06 cuml=26.06 python=3.10 'cuda-version>=12.0,<=12.5'
conda create -n rapids-26.08 -c rapidsai -c conda-forge -c nvidia \
cudf=26.08 cuml=26.08 python=3.10 'cuda-version>=12.0,<=12.5'
conda activate optuna-spark
pip install mysqlclient
pip install optuna joblib joblibspark ipywidgets
Expand Down Expand Up @@ -201,7 +201,7 @@ Or, create a cluster via the web UI:
- Under `Advanced Options > Spark > Environment variables`, set `LIBCUDF_CUFILE_POLICY=OFF`.
- Make sure to use a GPU cluster and include task GPU resources.

The init script will install the required libraries on all nodes, including RAPIDS and the Spark-RAPIDS plugin for GPU-accelerated ETL. On the driver, it will setup the MySQL server backend.
The init script will install the required libraries on all nodes, including RAPIDS and the cuDF plugin for GPU-accelerated ETL. On the driver, it will setup the MySQL server backend.

### 3. Run Notebook

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fi


# rapids import
SPARK_RAPIDS_VERSION=26.06.0
SPARK_RAPIDS_VERSION=26.08.0
curl -L https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/${SPARK_RAPIDS_VERSION}/rapids-4-spark_2.12-${SPARK_RAPIDS_VERSION}.jar -o \
/databricks/jars/rapids-4-spark_2.12-${SPARK_RAPIDS_VERSION}.jar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ json_config=$(cat <<EOF
"spark_version": "13.3.x-gpu-ml-scala2.12",
"spark_conf": {
"spark.task.resource.gpu.amount": "1",
"spark.executorEnv.PYTHONPATH": "/databricks/jars/rapids-4-spark_2.12-26.06.0.jar:/databricks/spark/python:/databricks/python3",
"spark.executorEnv.PYTHONPATH": "/databricks/jars/rapids-4-spark_2.12-26.08.0.jar:/databricks/spark/python:/databricks/python3",
"spark.executor.cores": "8",
"spark.rapids.memory.gpu.minAllocFraction": "0.0001",
"spark.plugins": "com.nvidia.spark.SQLPlugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
"source": [
"### PySpark\n",
"\n",
"For standalone users, we need to create the Spark session with the Spark-Rapids plugin. For Databricks users, the Spark session will be preconfigured and this cell can be skipped."
"For standalone users, we need to create the Spark session with the NVIDIA cuDF plugin for Apache Spark. For Databricks users, the Spark session will be preconfigured and this cell can be skipped."
]
},
{
Expand Down Expand Up @@ -451,10 +451,10 @@
],
"source": [
"def get_rapids_jar():\n",
" SPARK_RAPIDS_VERSION = \"26.06.0\"\n",
" SPARK_RAPIDS_VERSION = \"26.08.0\"\n",
" rapids_jar = f\"rapids-4-spark_2.12-{SPARK_RAPIDS_VERSION}.jar\"\n",
" if not os.path.exists(rapids_jar):\n",
" print(\"Downloading Spark Rapids jar\")\n",
" print(\"Downloading the cuDF plugin jar\")\n",
" url = f\"https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/{SPARK_RAPIDS_VERSION}/{rapids_jar}\"\n",
" response = requests.get(url)\n",
" if response.status_code == 200:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ Make sure you are in [this](./) directory.

7. Navigate to the notebook in your workspace and attach it to the cluster. The default cluster name is `spark-dl-inference-$FRAMEWORK`.

*Note that the RAPIDS Accelerator for Apache Spark is not compatible with this case, since [multiple GPUs per executor are not yet supported](https://docs.nvidia.com/spark-rapids/user-guide/latest/faq.html#why-are-multiple-gpus-per-executor-not-supported).
*Note that the NVIDIA cuDF plugin for Apache Spark is not compatible with this case, since [multiple GPUs per executor are not yet supported](https://docs.nvidia.com/spark-rapids/user-guide/latest/faq.html#why-are-multiple-gpus-per-executor-not-supported).
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ Make sure you are in [this](./) directory.
8. Open and run the notebook interactively with the **Python 3 kernel**.
The notebooks can be found under `Local Disk/spark-dl-notebooks` on the master node (folder icon on the top left > Local Disk).

*Note that the RAPIDS Accelerator for Apache Spark is not applicable in this case, since [multiple GPUs per executor are not yet supported](https://docs.nvidia.com/spark-rapids/user-guide/latest/faq.html#why-are-multiple-gpus-per-executor-not-supported).
*Note that the NVIDIA cuDF plugin for Apache Spark is not applicable in this case, since [multiple GPUs per executor are not yet supported](https://docs.nvidia.com/spark-rapids/user-guide/latest/faq.html#why-are-multiple-gpus-per-executor-not-supported).
6 changes: 3 additions & 3 deletions examples/ML+DL-Examples/Spark-Rapids-ML/pca/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ The notebook uses PCA to reduce a random dataset with 2048 feature dimensions to

Please refer to the Spark-Rapids-ML [README](https://github.com/NVIDIA/spark-rapids-ml/blob/HEAD/python) to setup the RAPIDS conda environment and install Spark-Rapids-ML dependencies.

## Download RAPIDS Jar from Maven Central
## Download the NVIDIA cuDF plugin for Apache Spark jar from Maven Central

Download the [Spark-Rapids plugin](https://nvidia.github.io/spark-rapids/docs/download.html#download-rapids-accelerator-for-apache-spark-v26060).
For Spark-RAPIDS-ML version 26.06.0, download the RAPIDS jar from Maven Central: [rapids-4-spark_2.12-26.06.0.jar](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.06.0/rapids-4-spark_2.12-26.06.0.jar).
Download the [cuDF plugin](https://nvidia.github.io/cudf-spark/docs/download.html#download-rapids-accelerator-for-apache-spark-v26080).
For Spark-RAPIDS-ML version 26.08.0, download the cuDF plugin jar from Maven Central: [rapids-4-spark_2.12-26.08.0.jar](https://repo1.maven.org/maven2/com/nvidia/rapids-4-spark_2.12/26.08.0/rapids-4-spark_2.12-26.08.0.jar).

## Running the Notebooks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"## Principal Component Analysis (PCA)\n",
"\n",
"In this notebook, we will demonstrate the end-to-end workflow of Spark RAPIDS accelerated PCA."
"In this notebook, we will demonstrate the end-to-end workflow of PCA accelerated by the NVIDIA cuDF plugin for Apache Spark."
]
},
{
Expand Down Expand Up @@ -57,7 +57,7 @@
" import os\n",
" import requests\n",
"\n",
" SPARK_RAPIDS_VERSION = \"26.06.0\"\n",
" SPARK_RAPIDS_VERSION = \"26.08.0\"\n",
" rapids_jar = f\"rapids-4-spark_2.12-{SPARK_RAPIDS_VERSION}.jar\"\n",
" if not os.path.exists(rapids_jar):\n",
" print(\"Downloading spark rapids jar\")\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/SQL+DF-Examples/demo/Spark_get_json_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"id": "Td_alkbOv3Aj"
},
"source": [
"# Spark RAPIDS get_json_object acceleration\n",
"# NVIDIA cuDF plugin for Apache Spark: get_json_object acceleration\n",
"\n"
]
},
Expand Down Expand Up @@ -41,7 +41,7 @@
"id": "ZfNDlz0SM0DB"
},
"source": [
"# Let's get started using the RAPIDS Accelerator for Apache Spark"
"# Let's get started using the cuDF plugin"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
" \"id\": \"Td_alkbOv3Aj\"\n",
" },\n",
" \"source\": [\n",
" \"# Spark RAPIDS Parquet acceleration\\n\",\n",
" \"# NVIDIA cuDF plugin for Apache Spark: Parquet acceleration\\n\",\n",
" \"\\n\"\n",
" ]\n",
" },\n",
Expand Down Expand Up @@ -50,7 +50,7 @@
" \"id\": \"ZfNDlz0SM0DB\"\n",
" },\n",
" \"source\": [\n",
" \"# Let's get started using the RAPIDS Accelerator for Apache Spark\"\n",
" \"# Let's get started using the cuDF plugin\"\n",
" ]\n",
" },\n",
" {\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"import os\n",
"# Change to your cluster ip:port and directories\n",
"SPARK_MASTER_URL = os.getenv(\"SPARK_MASTER_URL\", \"spark:your-ip:port\")\n",
"RAPIDS_JAR = os.getenv(\"RAPIDS_JAR\", \"/your-path/rapids-4-spark_2.12-26.06.0.jar\")\n"
"RAPIDS_JAR = os.getenv(\"RAPIDS_JAR\", \"/your-path/rapids-4-spark_2.12-26.08.0.jar\")\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/SQL+DF-Examples/retail-analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This repository contains two Jupyter notebooks:

Data Generation: This notebook generates sample data that can be used for analysis. It demonstrates how to use various Python libraries to create synthetic data sets that can be used for testing and experimentation. This notebook can be run in GCP n1-standard-32 instance type

Data Cleaning and Analysis: This notebook takes the generated data and performs a series of cleaning and analysis tasks. It demonstrates how to use Spark RAPIDS library to manipulate and analyze data sets.
Data Cleaning and Analysis: This notebook takes the generated data and performs a series of cleaning and analysis tasks. It demonstrates how to use the NVIDIA cuDF plugin for Apache Spark to manipulate and analyze data sets.
Loading