2020
GPU-ACCELERATED
MACHINE LEARNING INTRO
2
	
•  PMM	at	NVIDIA	
•  Author	of		free	Apache	Spark	3.0	
ebook:	
https://www.nvidia.com/en-us/deep-
learning-ai/solutions/data-science/
apache-spark-3/	
Carol	McDonald
3
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
GPU Accelerated Machine Learning
	
	
Agenda	
3
4
Agenda
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
5
What	is	AI?
6
AI	at	NSA,	MIT	Late	80s
7
Problems	with	hard	coded	Rules	
•  Rules	are	manual,		uses	a	human	expert	
–  difficult	to	maintain	
–  give	a	one	size	fits	all	decision!		(2	times	overdose	same	as	38	times)	
•  Machine	learning	uses	data	and	statistics		
–  can	give	sorted	probabilty,	can	precisely	match/target	individuals
8
What	is	Machine	Learning?	
Train Algorithm Build Model
Features
Predictions
f(X)
9
What	has	changed	in	the	past	10	years?	
Big	Data	and	Distributed	computing	
Improved	machine	learning	Algorithms
10
Apache	Spark	Distributed	Datasets	
Distributed Dataset
Node
Executor
P4
Node
Executor
P1 P3
Node
Executor
P2
partitioned
Partition	1	
8213034705,	95,	
2.927373,	
jake7870,	0……		
Partition	2	
8213034705,	115,	
2.943484,		
Davidbresler2,	1….	
Partition	3	
8213034705,	100,	
2.951285,	
gladimacowgirl,	
58…	
	
Partition	4	
8213034705,	117,	
2.998947,	daysrus,	
95….	
•  Data read into Memory Cache
•  Partitioned across a cluster
•  Operated on in parallel
•  Cached in memory for iterations
11
GPUs	speed	up	Multi	core	servers	for	parallel		processing	
Cluster of GPUs 1 million times faster than Cray-1
12
Mythbusters	explain	Parallel	GPU	vs	Sequential	CPU	
•  Painting	a	smily	face	with	a	sequential	paint	gun
13
Mythbusters	explain	Parallel	graphics	with	GPU		
•  Painting	a	smiling	face	with	one	blast	from	a	parallel	paint	gun	!
14
Agenda
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
15
Supervised	and	Unsupervised	Machine	Learning	
Machine Learning
Unsupervised
•  Clustering
•  Collaborative Filtering
•  Frequent Pattern Mining
Supervised
•  Classification
•  Regression
Label
16
Supervised	Algorithms	use	Labeled	Data
17
ML	Discovery	Model	Building	
Update	
Monitor
18
Supervised	Machine	Learning:	Classification	&	Regression	
Classification
Identifies
category for item
Spam	/	Not	Spam
19
Form	of	ML	that:	
•  Identifies	which	category	an	item	belongs	to		
•  Uses	supervised	learning	algorithms	
–  Data	is	labeled		
	
Classification:	Definition	
Sentiment
20
Credit	Card	Fraud	Example	
•  What	are	we	trying	to	predict?		
–  This	is	the	Label	or	Target	outcome:		
–  Fraud	or	Not	Fraud	
•  What	are	the	“if	questions”	or	properties	we	can	use	to	predict?		
–  These	are	the	Features:		
–  Is	the	amount	spent	today	>	historical	daily	average?		
–  Are	there	transactions	close	in	time	at	locations	far	apart	?	
–  Are	the	number	of	transactions	today	>	historical	average?	
–  Are	there	new	state	or	foreign	purchases?	
Credit	Card	Transaction	Features	
Number	of	Transactions	last	24	hours	
Total	$	Amount	last	24	hours	
Average	Amount	last	24	hours	
Average	Amount	last	24	hours	compared	to	historical	use	
Location	and	Time	difference	since	Last	Transaction	
Average	transaction		
fraud	risk	of	merchant	type	
Merchant	types	for	day	compared	to	historical	use	
Features derived
From Transaction
History
21
Decision	Tree	For	Classification	
•  Tree of decisions about features
•  Estimates IF THEN ELSE questions
•  Gives probability of a correct decision
Is the amount spent in 24 hours >
average
Is the number of
states used from > 2
Are there multiple
Purchases today from
risky merchants?
YES NO
NoYES
Fraud
90%
Not Fraud
50%
Fraud
90%
Not Fraud
30%
YES No
22
•  Random	Forest	model	consists	of	multiple	
decision	trees	from	subsets	of	data	
•  Final	Prediction	is	combined	average	
output	of	all	trees	
•  Improves	accuracy	
•  Gradient	Boosted	Decision	Trees	
•  Iteratively	uses	residual	error	to	improve	
multiple	trees.	Final	prediciton	weighted	
sum.		
•  XGBoost	distributed	faster	version	of	GBDT		
Random	Forest,	Gradient	Boosting	Decision	Trees,	XGBoost
23
Examples	
•  Retail	Example:	
–  Predict	price,	sales		
•  Telecom:	
–  Predict	customer	will	churn	
•  Healthcare	Example:			
–  Probability	of	readmission	
•  Marketing	
–  Predict	probability	customer	will	click	on	add
24
Supervised	Learning	House	Price	Prediction	Example	
•  What	are	we	trying	to	predict?		
–  This	is	the	Label	or	Target	outcome:		
–  The	house	price	$	
•  What	are	the	“if	questions”	or	properties	we	can	use	to	predict?		
–  These	are	the	Features:		
–  The	size	of	the	house	(square	meters)
25
Label:
House Price
Y
X
Feature: house size
(square meters)
Data point: price, size
House Price = intercept + coefficient * house size
y = a + bx
House	Price	Regression	Example
26
Decision	Tree	for	House	Price
27
Regression	Predicts	a	Numeric	Value	
•  Regression	predicts	a	numeric	value	(eg	price)	
•  Retail	Example:	
–  Sales	based	on	an	event	
•  Healthcare	Example:			
–  Days	of	hospital	stay
28
Agenda
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
29
Supervised	and	Unsupervised	Machine	Learning	
Machine Learning
Unsupervised
•  Clustering
•  Collaborative Filtering
•  Frequent Pattern Mining
Supervised
•  Classification
•  Regression
Label
30
Unsupervised	Algorithms	use	Unlabeled	data	
Customer GroupsBuild ModelTrain Algorithm
Finds patterns
New Customer
Purchase Data
Use Model
Similar Customer Group
Contains patterns Recognizes patterns
Customer purchase
data
31
Unsupervised	Machine	Learning:	Clustering	
Clustering
group news articles into different categories
32
Clustering:	Definition	
Groups	objects	into	clusters		
	with	high	feature	similarity
33
Uses	of	Clustering	
Clustering	Examples	include:	
•  Grouping:	
–  Similar	search	results	,	text	
–  Similar	customers	
–  Patient	similarity	
–  Similar	Products		
•  Anomaly	detection:	finding	outliers,	what’s	outside	
of	the	groups	not	similar
34
Clustering:	Example	
Group	similar	objects
35
Clustering:	Example	
Group	similar	objects	
Use	MLlib	K-means	algorithm	
1.  Initialize coordinates to K cluster centers
36
Clustering:	Example	
Group	similar	objects	
Use	MLlib	K-means	algorithm	
1.  Initialize coordinates to K clusters
centers (centroid)
2.  Assign all points to nearest cluster
center (centroid)
37
Clustering:	Example	
Group	similar	objects	
Use	MLlib	K-means	algorithm	
1.  Initialize coordinates to center of clusters
(centroid)
2.  Assign all points to nearest centroid
3.  Update centroids to center of assigned
points
38
Clustering:	Example	
Group	similar	objects	
Use	MLlib	K-means	algorithm	
1.  Initialize coordinates to center of clusters
(centroid)
2.  Assign all points to nearest centroid
3.  Update centroids to center of points
4.  Repeat until conditions met
39
Association,	Co-Occurrence,	Market	Basket		Recommendations	
•  Retail		
–  Products	which	are	purchased	
together	
•  		Take	action:	
–  Store	layouts	
–  Which	products	to	put	on	
specials,	promote,	coupons…	
•  Healthcare	
–  Patients	like	mine	cohorts
40
Agenda
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
41
Deep	Learning	
Multilayered	neural	networks
42
The	Network	is	trained	with	images
43
Neural	network	neuron		or	node		
Each	node	takes	input	data	and	a	weight	and	outputs	a	confidence	score	to	the	next	layer
44
Each	node	outputs	a	confidence	score	to	the	next	layer
45
Errors	are	calculted	at	the	output	layer
46
Errors	are	sent	back	through	the	network
47
This	process	is	repeated,	adjusting	weights,	until	correct
48
This	process	is	repeated	with	lots	of	images
49
Deep	Learning	
During	this	process	layers	learn	the	optimal	features	for	the	model
50
Deep	Learning	Features	
•  Advantage:	
–  Features	do	not	have	to	be	
predetermined	
•  Disadvantage:	
–  Decisions	are	a	black	box	
Feature
Decisions
?
51
Deep	Neural	Networks	
•  Classification	and	
•  Forecasting
52
Convolutional	Neural	Networks	for	Images	
•  Image	crunchers	to	identify	objects		
•  Today’s	eyes	for	identifying	cancer,	driving	cars,	
oil	exploration
53
Recurrent	Neural	Networks	for	Sequenced	data	
•  Sequence	of	events	and	language	patterns	
•  Amazon’s	Alexa,	Apple’s	Siri,	Google’s	
autocomplete,	fraud,	stock	predictions	and	
algorithmic	trading
54
Agenda
Introduction to Machine Learning
Supervised Machine Learning
Unsupervised Machine Learning
Deep Learning
GPUs
55
GPUs have been responsible for the advancement of deep learning in the
past several years	
https://developer.nvidia.com/deep-learning-software
56
cuDF cuIO
Analytics
Data Preparation VisualizationModel Training
cuML
Machine Learning
cuGraph
Graph Analytics
PyTorch, TensorFlow,
MxNet
Deep Learning
cuxfilter, pyViz,
plotly
Visualization
Dask
GPU Memory
RAPIDS	
End-to-End	Accelerated	GPU	Data	Science	
https://developer.nvidia.com/blog/building-an-accelerated-data-science-ecosystem-rapids-hits-two-years/
57
� All systems utilize the same memory format
� No overhead for cross-system communication
� Projects can share functionality (eg, Parquet-to-
Arrow reader)
Source: From Apache Arrow Home Page - https://arrow.apache.org/
GPU	DataFrame	and	Apache	Arrow
58
Data	processing	challenges	with	CPU-powered	spark	
Hadoop	brought	scale-out	processing	to	data	analytics	
ETL and traditional machine-learning
workloads continued to be written with
tools like Scikit-Learn or multi-CPU
distributed solutions like Spark.
Limited	Horizontal	Scalability	
2030202020102000
Data Processing
Requirements
CPU
Gap in Data
Processing
Data to
Analyze
CPU
Processing
Hadoop Era Spark Era
59
DATA	PROCESSING	SOLUTION	FOR	TODAY	AND	TOMORROW	
	
Spark	3.0	on	GPUs	
Spark	3.0	clusters	can	now	be	accelerated	using	
RAPIDS	software	and	NVIDIA	GPUs	
and	exceed	data	processing	requirements
60
BENEFITS OF GPU ACCELERATED SPARK 3.0	
Accelerate data science pipelines without code changes
One	pipeline,	from	ingest	to	data	prep	to	training	
Data	preparation	and	model	training	are	both	GPU-accelerated	
Infrastructure	is	consolidated	and	simplified
61
NVIDIA	innovations	in	Spark	3.0	
•  RAPIDS	Accelerator	for	Spark	
3.0	GPU	Acceleration	of:		
•  Spark	Data	Frames	
•  Spark	SQL	
•  Shuffle	
Accelerating	Spark	pipelines	end-to-end
62
To	dive	deeper	into	Apache	Spark	3.0,	
download	the	free	Apache	Spark	3.0	
ebook:	
https://www.nvidia.com/en-us/deep-
learning-ai/solutions/data-science/
apache-spark-3/	
TO	LEARN	MORE
63
•  Developers	https://developer.nvidia.com/	
•  RAPIDS	https://developer.nvidia.com/rapids	
•  Deep	Learning	https://developer.nvidia.com/deep-learning	
•  https://news.developer.nvidia.com/oak-ridge-national-laboratory-coronavirus-
research/	
•  https://developer.nvidia.com/blog/jumpstarting-ai-with-covid-19-ct-inference-
pipeline-and-clara-deploy-quickstart-vm/	
•  https://news.developer.nvidia.com/	
•  https://news.developer.nvidia.com/new-resource-for-nvidia-developers-access-
technical-content-through-nvidia-on-demand/	
•  https://blazingsql.com/	
TO	LEARN	MORE
64
Integrations, feedback, documentation support, pull requests, new issues, or code donations welcomed!
APACHE ARROW
GPU OPEN ANALYTICS
INITIATIVE
https://arrow.apache.org/
@ApacheArrow
http://gpuopenanalytics.com/
@GPUOAI
RAPIDS
https://rapids.ai
@RAPIDSAI
DASK
https://dask.org
@Dask_dev
Join	the	Movement	
Everyone Can Help!
65
GITHUB DOCKER
https://github.com/rapidsai
ANACONDA NGC
https://anaconda.org/rapidsai/ https://ngc.nvidia.com/registry/
nvidia-rapidsai-rapidsai
https://hub.docker.com/r/
rapidsai/rapidsai/
RAPIDS	
How Do I Get the Software?

Introduction to machine learning with GPUs