Quickstart#
spark-rapids-user-tools CLI enables user to run the tool for logs from a number of CSP platforms in addition to on-prem.
Tip
For most accurate results, it is recommended to run the latest version of the CLI tool.
Databricks users can run the tool using a demo notebook.
Install#
Prerequisites#
Set up a Python environment with a version between 3.8 and 3.10
Java 8+
The developer machine used to host the CLI needs internet access. If the machine is behind a proxy, it is recommended to install the CLI package from source using fat mode as described in Install the CLI Package.
Set up the development environment for your CSP or on-prem
No more steps required to run the tools on on-premises environment including standalone/local machines.
The tools CLI depends on Python implementation of PyArrow which relies on some environment variables to bind with HDFS:
HADOOP_HOME
: the root of your installed Hadoop distribution. Often has “lib/native/libhdfs.so”.JAVA_HOME
: the location of your Java SDK installation.ARROW_LIBHDFS_DIR
(optional): explicit location of “libhdfs.so” if it is installed somewhere other than $HADOOP_HOME/lib/native.Add the Hadoop jars to your CLASSPATH.
export CLASSPATH=`$HADOOP_HOME/bin/hadoop classpath --glob`
%HADOOP_HOME%/bin/hadoop classpath --glob > %CLASSPATH%
For more information on HDFS requirements, refer to the PyArrow HDFS documentation
Install gcloud CLI. Follow the instructions on gcloud-sdk-install
Set the configuration settings and credentials of the gcloud CLI:
Initialize the gcloud CLI by following these instructions
Grant authorization to the gcloud CLI with a user account
Set up “application default credentials” to the gcloud CLI by logging in
Manage gcloud CLI configurations. For more details, visit gcloud-sdk-configurations
Verify that the following gcloud CLI properties are properly defined:
dataproc/region
compute/zone
compute/region
core/project
If the configuration is not set to default values, then make sure to explicitly set some environment variables to be picked up by the tools cmd such as: CLOUDSDK_DATAPROC_REGION, and CLOUDSDK_COMPUTE_REGION.
The tools CLI follows the process described in this doc to resolve the credentials. If not running on (GCP), the environment variable
GOOGLE_APPLICATION_CREDENTIALS
is required to point to a JSON file containing credentials.
Install the AWS CLI version 2. Follow the instructions on aws-cli-getting-started
Set the configuration settings and credentials of the AWS CLI by creating credentials and config files as described in aws-cli-configure-files.
If the AWS CLI configuration is not set to the default values, then make sure to explicitly set some environment variables tp be picked up by the tools cmd such as:
AWS_PROFILE
,AWS_DEFAULT_REGION
,AWS_CONFIG_FILE
,AWS_SHARED_CREDENTIALS_FILE
. See the full list of variables in aws-cli-configure-envvarsNote that it is important to configure with the correct region for the bucket being used on S3. If region is not set, the AWS SDK will choose a default value that may not be valid. In addition, the tools CLI by inspects
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
emvironment variables if the credentials could not be pulled from the credential files.
Note
In order to be able to run tools that require SSH on the EMR nodes (i.e., bootstrap), then:
make sure that you have SSH access to the cluster nodes; and
create a key pair using Amazon EC2 through the AWS CLI command
aws ec2 create-key-pair
as instructed in aws-cli-create-key-pairs.
The tool currently only supports event logs stored on S3 (no DBFS paths). The remote output storage is also expected to be S3.
Install Databricks CLI
Install the Databricks CLI version 0.200+. Follow the instructions on Install the CLI.
Set the configuration settings and credentials of the Databricks CLI:
Set up authentication by following these instructions
Verify that the access credentials are stored in the file ~/.databrickscfg on Unix, Linux, or macOS, or in another file defined by environment variable DATABRICKS_CONFIG_FILE.
If the configuration is not set to default values, then make sure to explicitly set some environment variables to be picked up by the tools cmd such as: DATABRICKS_CONFIG_FILE, DATABRICKS_HOST and DATABRICKS_TOKEN. See the description of the variables in environment variables docs.
Setup the environment to access S3
Install the AWS CLI version 2. Follow the instructions on aws-cli-getting-started
Set the configuration settings and credentials of the AWS CLI by creating credentials and config files as described in aws-cli-configure-files.
If the AWS CLI configuration is not set to the default values, then make sure to explicitly set some environment variables tp be picked up by the tools cmd such as:
AWS_PROFILE
,AWS_DEFAULT_REGION
,AWS_CONFIG_FILE
,AWS_SHARED_CREDENTIALS_FILE
. See the full list of variables in aws-cli-configure-envvarsNote that it is important to configure with the correct region for the bucket being used on S3. If region is not set, the AWS SDK will choose a default value that may not be valid. In addition, the tools CLI by inspects
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
emvironment variables if the credentials could not be pulled from the credential files.
Note
In order to be able to run tools that require SSH on the EMR nodes (i.e., bootstrap), then:
make sure that you have SSH access to the cluster nodes; and
create a key pair using Amazon EC2 through the AWS CLI command
aws ec2 create-key-pair
as instructed in aws-cli-create-key-pairs.
The tool currently only supports event logs stored on ABFS. The remote output storage is also expected to be ABFS (no DBFS paths).
Install Databricks CLI
Install the Databricks CLI version 0.200+. Follow the instructions on Install the CLI.
Set the configuration settings and credentials of the Databricks CLI:
Set up authentication by following these instructions
Verify that the access credentials are stored in the file ~/.databrickscfg on Unix, Linux, or macOS, or in another file defined by environment variable DATABRICKS_CONFIG_FILE.
If the configuration is not set to default values, then make sure to explicitly set some environment variables to be picked up by the tools cmd such as: DATABRICKS_CONFIG_FILE, DATABRICKS_HOST and DATABRICKS_TOKEN. See the description of the variables in environment variables docs.
Install Azure CLI
Install the Azure CLI. Follow the instructions on How to install the Azure CLI.
Set the configuration settings and credentials of the Azure CLI:
Set up the authentication by following these instructions.
Configure the Azure CLI by following these instructions.
location is used for retreving instance type description (default is westus).
output should use default of json in core section.
Verify that the configurations are stored in the file $AZURE_CONFIG_DIR/config where the default value of AZURE_CONFIG_DIR is $HOME/.azure on Linux or macOS.
If the configuration is not set to default values, then make sure to explicitly set some environment variables to be picked up by the tools cmd such as: AZURE_CONFIG_DIR and AZURE_DEFAULTS_LOCATION.
Install the CLI Package#
pip install spark-rapids-user-toolsIf you need more details, please find in RAPIDS user tools pip package.
pip install <wheel-file>
Checkout the code repository
git clone git@github.com:NVIDIA/spark-rapids-tools.git cd spark-rapids-tools/user_toolsOptional: Run the project in a virtual environment
python -m venv .venv source .venv/bin/activateBuild wheel file using one of the following modes:
- Fat mode
Similar to fat jar in Java, this mode solves the problem when web access is not available to download resources having Url-paths (http/https). The command builds the tools jar file and downloads the necessary dependencies and packages them with the source code into a single wheel file. You may consider this mode if the development environment has no access to download dependencies (i.e., Spark jars) during runtime.
./build.sh fat
- Default mode
This mode builds a wheel package without any jar dependencies
./build.shFinally, install the package using the wheel file
pip install <wheel-file>
Running the Tool#
A typical workflow to successfully run the qualification
command:
Follow the instructions to set up the prerequisites and install the CLI
Get Apache Spark eventlogs from prior runs of CPU based applications on Spark 2.x or later. In addition to local storage, the eventlogs should be stored in a valid remote storage:
Run the
qualification
command on the set of selected eventlogs. Event logs can be passed as single files, a directory, a comma-separated list of files or directories. The format of event logs can be raw, zip, or gzip.
spark_rapids qualification <flags>
The tool helps quantify the expected acceleration of migrating a Spark application or query to GPU. The tool will process each app individually, but will group apps with the same name and cluster details into a single output row after averaging duration metrics accordingly.
Example Commands#
This section shows examples of Qualification CLI commands assuming the following inputs:
CLUSTER_NAME
: The cluster name on CSP (for Dataproc or EMR platform, not applicable for on-prem clusters)CLUSTER_ID
: The cluster ID on CSP (for Databricks-AWS or Databricks-Azure platform, not applicable for on-prem clusters)CLUSTER_PROPS
: The cluster properties file (for all platforms). See Cluster by Property File under Cluster Metadata on how to generate this file.EVENTLOG
: Path to Spark eventlogs without the scheme part. The scheme can be a local file system (file://
), HDFS (hdfs://
), S3 (s3://
), ABFS (abfss://
), or GCS (gs://
).
The following table shows CLI command examples along with platform and expected functionalities based on which analysis is performed.
CMD |
Platform |
---|---|
spark_rapids qualification \
--cluster $CLUSTER_NAME \
--eventlogs gs://$EVENTLOG
|
Dataproc |
spark_rapids qualification \
--cluster $CLUSTER_NAME \
--eventlogs s3://$EVENTLOG
|
EMR |
spark_rapids qualification \
--cluster $CLUSTER_ID \
--platform databricks-azure \
--eventlogs file://$EVENTLOG
|
Databricks-Azure |
spark_rapids qualification \
--cluster $CLUSTER_PROPS \
--eventlogs file://$EVENTLOG
|
Databricks-AWS |
spark_rapids qualification \
--eventlogs file://$EVENTLOG
|
On-prem |
Command Options#
You can list all the options using the help
argument
spark_rapids qualification -- --help
Available options are listed in the following table.
Option |
Description |
Default |
Required |
---|---|---|---|
|
Event log filenames or CSP storage directories containing event logs (comma separated). Skipping this argument requires that the |
N/A |
N |
|
The CPU cluster on which the Spark application(s) were executed. Name or ID of cluster or path to cluster property file. Further details described in Cluster Metadata. |
N/A |
N |
|
Defines one of the following “on-prem”, “emr”, “dataproc”, “dataproc-gke”, “databricks-aws”, and “databricks-azure”. |
N/A |
N |
|
Speedup recommendation for comparable cluster in |
N/A |
N |
|
Path to store the output. |
N/A |
N |
|
Requires
|
|
N |
|
Model used to calculate the estimated GPU duration:
|
|
N |
|
Path to a bundled jar including Rapids tool. The path is a local filesystem, or remote cloud storage url. If missing, the wrapper downloads the latest rapids-4-spark-tools_*.jar from maven repository. |
N/A |
N |
|
The maximum heap size of the JVM in gigabytes. Default is calculated based on a function of the total memory of the host. |
N/A |
N |
|
Number of thread to use for parallel processing on the eventlogs batch. Default is calculated as a function of the total number of cores and the heap size on the host. |
N/A |
N |
|
Requires
|
|
N |
|
True or False to enable verbosity of the script. |
N/A |
N |
Cluster-Metadata#
By default, the qualification tool generates estimated speedups of the CPU applications. It will also generate a cluster recommendation for running on GPU. To aid that recommendation, you can provide the CPU cluster information.
The specific type of parameter passed for the cluster is based on platform, see the following scenarios to determine which method to use for your platform:
User can pass name of the cluster
CLUSTER_NAME
to the command:spark_rapids qualification --cluster $CLUSTER_NAME [flags]This is supported on Dataproc and EMR platform. The tool uses the CSP CLI to collect the cluster information.
User can pass ID of the cluster
CLUSTER_ID
to the command:spark_rapids qualification --cluster $CLUSTER_ID [flags]This is supported on Databricks-AWS and Databricks-Azure platform. The tool uses the CSP CLI to collect the cluster information.
User can pass
CLUSTER_PROPS
- the path to cluster property file (in json/yaml formats) to the command. This is useful if the cluster is not accessible or permanently deleted.spark_rapids qualification --cluster $CLUSTER_PROPS [flags]User defines the cluster configuration of on-prem platform. The following is a sample cluster property file
CLUSTER_PROPS
in yaml format.config: masterConfig: numCores: 2 memory: 7680MiB workerConfig: numCores: 8 memory: 7680MiB numWorkers: 2
target_platform
is required for on-prem clusters. Currently only Dataproc is supported.Given Dataproc
CLUSTER_NAME
, user can generate its cluster property fileCLUSTER_PROPS
using the following command. (See gcloud CLI docs)gcloud dataproc clusters describe $CLUSTER_NAME > $CLUSTER_PROPSGiven EMR
CLUSTER_ID
, user can generate its cluster property fileCLUSTER_PROPS
using the following command. (See AWS CLI docs)aws emr describe-cluster --cluster-id $CLUSTER_ID > $CLUSTER_PROPSGiven Databricks
CLUSTER_ID
, user can generate its cluster property fileCLUSTER_PROPS
using the following command. (See Databricks CLI docs)databricks clusters get $CLUSTER_ID > $CLUSTER_PROPSGiven Databricks
CLUSTER_ID
, user can generate its cluster property fileCLUSTER_PROPS
using the following command. (See Databricks CLI docs)databricks clusters get $CLUSTER_ID > $CLUSTER_PROPS
Qualification Output#
The Qualification tool will run against logs from your CSP environment and then will output the applications recommended for acceleration along with Estimated GPU Speedup.
The command creates a directory with UUID that contains the following:
Directory generated by the RAPIDS qualification tool rapids_4_spark_qualification_output;
A CSV file that contains the summary of all the applications (qualification_summary.csv)
1 qual_20230314145334_d2CaFA34 2 ├── qualification_summary.csv 3 └── rapids_4_spark_qualification_output/ 4 ├── ui/ 5 │ └── html/ 6 ...
Note
See this listing for full details of the subdirectory rapids_4_spark_qualification_output
.
In qualification_summary.csv, the command output lists these key fields for each application:
- App ID#
An application is referenced by its application ID, app-id. When running on YARN, each application may have multiple attempts, but there are attempt IDs only for applications in cluster mode, not applications in client mode. Applications in YARN cluster mode can be identified by their attempt-id.
- App Name#
Name of the application
- App Duration#
Wall-Clock time measured since the application starts till it is completed. If an app is not completed an estimated completion time would be computed.
- Estimated GPU Duration#
Predicted runtime of the app if it was run on GPU.
It is the sum of the accelerated operator durations and ML functions duration(if applicable) along with durations that could not run on GPU because they are unsupported operators or not SQL/Dataframe.- Estimated GPU Speedup#
That will estimate how much faster the application would run on GPU. It is calculated as the ratio between App Duration and Estimated GPU Duration.
- Estimated GPU Speedup Category#
This is the qualification result per job to determine if the job is a good candidate for running on GPU. A value of Large, Medium, or Small indicates the job should be migrated to GPU with different levels of confidence for expected acceleration. A value of Not Recommended or Not Applicable indicates the job should not be migrated to GPU.
1 +----+----------+---------------------+------------------+
2 | | App ID | App Name | Estimated GPU |
3 | | | | Speedup Category |
4 +----+----------+---------------------+------------------+
5 | 0 | app-0002 | spark_data_utils.py | Large |
6 | 3 | app-0001 | Spark shell | Medium |
7 +----+----------+---------------------+------------------+
For more information on the detailed output of the Qualification tool, go here: Output Details.