Top Banner
Miguel Martínez RAPIDS GPU POWERED MACHINE LEARNING
35

RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

May 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Miguel Martínez

RAPIDSGPU POWERED MACHINE LEARNING

Page 2: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

WHAT IS RAPIDS

Page 3: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

RAPIDS

RAPIDSGPU Accelerated End-to-End Data Science

RAPIDS is a set of open source libraries for GPU accelerating data preparation and machine learning.

OSS website: rapids.ai

GPU Memory

Data Preparation VisualizationModel Training

cuGraphGraph Analytics

cuMLdask-cuML

Machine Learning

cuDFdask-cuDF

Data Preparation

Page 4: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

RAPIDS

RAPIDS LIBRARIEScuDF

• GPU-accelerated lightweight in-GPU memory database used for data preparation

• Accelerates loading, filtering, and manipulation of data for model training data preparation

• Python drop-in Pandas replacement built on CUDA C++

cuML

• GPU accelerated traditional machine learning libraries• XGBoost, PCA, Kalman, K-means, k-NN, DBScan, tSVD …

cuGRAPH

• Collection of graph analytics libraries.

Page 5: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

HOW TO SETUP AND START USING RAPIDS

Page 6: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Cloud

HOW? DOWNLOAD AND DEPLOY

On-premises

Source available on GitHub | Container available on NGC and Docker Hub | Conda and PIP

NGC

https://github.com/rapidsaihttps://ngc.nvidia.com

https://hub.docker.com/u/rapidsai

https://anaconda.org/rapidsaihttps://pypi.org/project/cudf/https://pypi.org/project/cuml/

Pascal GPU architecture or betterCUDA 9.2 or 10.0

Ubuntu 16.04 or 18.04

Page 7: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

RUNNING RAPIDS CONTAINER IN THE CLOUDA step-by-step installation guide (MS Azure)

1. Create a NC6s_v2 virtual machine instance on Microsoft AzurePortal using NVIDIA GPU Cloud Image for Deep Learning and HPCas image.

2. Start the virtual machine.

3. Connect to the virtual machine using the following command:$ ssh -L 8080:localhost:8888 \

-L 8787:localhost:8787 \username@public_ip_address

4. Pull the RAPIDS container from NGC. Run it.

$ docker pull nvcr.io/nvidia/rapidsai/rapidsai:cuda10.0-runtime-ubuntu18.04$ docker run --runtime=nvidia \

--rm -it \-p 8888:8888 \-p 8787:8787 \-p 8786:8786 \nvcr.io/nvidia/rapidsai/rapidsai:cuda10.0-runtime-ubuntu18.04

5. Run JupyterLab:

(rapids)$ bash /rapids/notebooks/utils/start-jupyter.sh

6. Open your browser, and navigate to http://localhost:8080.

7. Navigate to:

• cuml folder for cuML IPython examples.

• mortgage folder for XGBoost IPython examples.

8. Enjoy!

Page 8: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

RUNNING RAPIDS CONTAINER IN THE CLOUDA step-by-step installation guide (AWS)

1. Create a p3.8xlarge machine instance on Amazon Web Servicesusing NVIDIA Volta Deep Learning AMI as image.

2. Start the virtual machine.

3. Connect to the virtual machine using the following command:$ ssh -L 8080:localhost:8888 \

-L 8787:localhost:8787 \ubuntu@public_ip_address

4. Pull the RAPIDS container from NGC. Run it.

$ docker pull nvcr.io/nvidia/rapidsai/rapidsai:cuda10.0-runtime-ubuntu18.04$ docker run --runtime=nvidia \

--rm -it \-p 8888:8888 \-p 8787:8787 \-p 8786:8786 \nvcr.io/nvidia/rapidsai/rapidsai:cuda10.0-runtime-ubuntu18.04

5. Run JupyterLab:

(rapids)$ bash /rapids/notebooks/utils/start-jupyter.sh

6. Open your browser, and navigate to http://localhost:8080.

7. Navigate to:

• cuml folder for cuML IPython examples.• mortgage folder for XGBoost IPython examples.

8. Enjoy!

Page 9: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

HOW TO PORT EXISTING CODE

Page 10: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

CPU vs GPUPORTING EXISTING CODE

PCA

Principal Component Analysis (PCA)…Now!Before…

Training results:• CPU: 57.1 seconds• GPU: 4.28 seconds

System: AWS p3.8xlargeCPUs: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz, 32 vCPU cores, 244 GB RAMGPU: Tesla V100 SXM2 16GBDataset: https://github.com/rapidsai/cuml/tree/master/python/notebooks/data

Page 11: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

…Now!Before…k-Nearest Neighbors (KNN)

CPU vs GPUPORTING EXISTING CODE

KNN

Training results:• CPU: ~9 minutes• GPU: 1.12 seconds

System: AWS p3.8xlargeCPUs: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz, 32 vCPU cores, 244 GB RAMGPU: Tesla V100 SXM2 16GBDataset: https://github.com/rapidsai/cuml/tree/master/python/notebooks/data

Page 12: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

TRAINING TIME COMPARISONCPU vs GPU

The bigger the dataset is, the higher the training performance difference is

between CPU and GPU.

Dataset size trained in 15 minutes.CPU: ~130.000 rows.

GPU: ~5.900.000 rows.

Specs NC6s_vs

Cores(Broadwell 2.6Ghz)

6

GPU 1 x P100

Memory 112 GB

Local Disk ~700 GB SSD

Network Azure Network

Page 13: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

WHAT IS XGBOOST

Page 14: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

XGBOOST

XGBoost is an implementation of gradientboosted decision trees designed for speedand performance.

Definition

It is a powerful tool forsolving classification andregression problems in asupervised learning setting.

Page 15: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Source: https://goo.gl/C6WKiF

Example of Decision TreePREDICT: WHO ENJOYS COMPUTER GAMES

Page 16: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Source: https://goo.gl/C6WKiF

Example of Using Ensembled Decision TreesCOMBINE TREES FOR STRONGER PREDICTIONS

Page 17: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Source: https://goo.gl/GWNdEm

Models fit to the Boston Housing Dataset.

Single Decision Tree vs Ensembled Decision TreesTRAINED MODELS VISUALIZATION

Page 18: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

WHY XGBoost

Page 19: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Winner of Caterpiller Kaggle Contest 2015– Machinery component pricing

Winner of CERN Large Hadron Collider Kaggle Contest 2015 – Classification of rare particle decay phenomena

Winner of KDD Cup 2016 – Research institutions’ impact on the acceptance of submitted academic papers

Winner of ACM RecSys Challenge 2017– Job posting recommendation

A STRONG HISTORY OF SUCCESSOn a Wide Range of Problems

Page 20: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

WHICH ML ALGORITHM PERFORMS BESTAverage rank across 165 ML datasets

Source: https://goo.gl/aztMh2

LowerIs

Better

Page 21: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

WHY XGBOOST + RAPIDS

Page 22: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

XGBoost:

Algorithm tuned for eXtreme performance and high efficiency

Multi-GPU and Multi-Node Support

RAPIDS:

End-to-end data science & analytics pipeline entirely on GPU

User-friendly Python interfaces

Faster results helps hyperparameter tuning

Relies on CUDA primitives, exposes parallelism and high-memory bandwidth

Multi-GPU, Multi-Node, ScalabilityWHY RAPIDS WITH XGBOOST

Page 23: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

BENCHMARKS

2.290

1.956

1.999

1.948

169

157

0 500 1.000 1.500 2.000 2.500

20 CPU Nodes

30 CPU Nodes

50 CPU Nodes

100 CPU Nodes

DGX-2

5x DGX-1

0 2.000 4.000 6.000 8.000 10.000

20 CPU Nodes

30 CPU Nodes

50 CPU Nodes

100 CPU Nodes

DGX-2

5x DGX-1

2.741

1.675

715

379

42

19

0 1.000 2.000 3.000

20 CPU Nodes

30 CPU Nodes

50 CPU Nodes

100 CPU Nodes

DGX-2

5x DGX-1

Benchmark

200GB CSV dataset; Data preparation includes joins, variable transformations.

CPU Cluster Configuration

CPU nodes (61 GiB of memory, 8 vCPUs, 64-bit platform), Apache Spark

DGX Cluster Configuration

5x DGX-1 on InfiniBand network

Time in seconds — Shorter is better

cuDF (Load and Data Preparation) Data Conversion XGBoost

cuDF – Load and Data Prep cuML – XGBoost End-to-End

8,763

6,147

3,926

3,221

322

213

Page 24: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

cuML Algorithms Available Now Q2-2019

XGBoost GBDT MGMN

XGBoost Random Forest MGMN

K-Means Clustering MG

K-Nearest Neighbors (KNN) MG

Principal Component Analysis (PCA) SG

Density-based Spatial Clustering of Applications with Noise (DBSCAN) SG

Truncated Singular Value Decomposition (tSVD) SG

Uniform Manifold Aproximation and Projection (UMAP) SG MG

Kalman Filters (KF) SG

Ordinary Least Squares Linear Regression (OLS) SG

Stochastic Gradient Descent (SGD) SG

Generalized Linear Model, including Logistic (GLM) MG

Time Series (Holts-Winters) SG

Autoregressive Integrated Moving Average (ARIMA) SG

Last updated 29.03.19

SGSingle GPU

MGMulti-GPU

MGMNMulti-GPU Multi-Node

cuML ROADMAP

Page 25: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

LEARN MORE ABOUT RAPIDS

Page 26: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

https://rapids.ai

Page 27: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

CUDF CODE SAMPLES

Page 28: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Create an empty DataFrame, and add a column. Create a DataFrame with two columns.

Load a CSV file into a GPU DataFrame. Use Pandas to load a CSV file, and copy its content into a GPU DataFrame.

LOADING DATA INTO A GPU DATAFRAME

Page 29: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Row slicing with column selection.

Find the mean and standard deviation of a column.

Change the data type of a column. Transform column values with a custom function.

Return the first three rows as a new DataFrame.

Count number of occurrences per value, and number of unique values.

WORKING WITH GPU DATAFRAMES

Page 30: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

Row slicing with column selection.

Query the columns of a DataFrame with a boolean expression. Sort a column by its values.

Return the first ‘n’ rows ordered by ‘columns’ in ascending order.

Join columns with other DataFrame on index. Merge two DataFrames.

Group by column with aggregate function.

One-hot encoding.

QUERY, SORT, GROUP, JOIN, MERGE, ONE-HOT ENCODING

Page 31: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

SUMMARY

Page 32: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

RAPIDS

GPU Accelerated Data Science

RAPIDS is a set of open source libraries for GPU accelerating data preparationand machine learning.

Visit www.rapids.ai

Page 33: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

ONE MORE THING

Page 34: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal

MESSAGE TODATA SCIENTISTS

FIND A NEW ARGUMENT

Page 35: RAPIDS · 2019-04-09 · RUNNING RAPIDS CONTAINER IN THE CLOUD A step-by-step installation guide (MS Azure) 1. Create a NC6s_v2 virtual machine instance on Microsoft Azure Portal