getting started with tensorflow on gpus · getting started with tensorflow on gpus 1 magnus...

65
Geing Staed with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten

Upload: others

Post on 04-Aug-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Getting Started with TensorFlow on GPUs

1

Magnus Hyttsten@MagnusHyttsten

Page 2: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

+

Agenda

Page 3: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

An Awkward Social Experiment(that I'm afraid you will be part of...)

Page 4: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 5: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

ROCKS!

Page 6: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Examples(Train & Test Data)

Model(Your Brain)

Output

Input Data

"GTC"

<Awkward Silence>

Page 7: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Examples(Train & Test Data)

Model(Your Brain)

Loss function

Output

Input DataLabels(Correct Answers)

Optimizer

"GTC"

"Rocks"

Page 8: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Examples(Train & Test Data)

Model(Your Brain)

Loss function

Output

Input DataLabels(Correct Answers)

Optimizer

"GTC"

"Rocks""Rocks"

Page 9: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

"Classical"Programming

Machine Learning

Input Data+

Code

Input Data+

Output Data

Output Data

Code

Page 10: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 11: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 12: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 13: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 14: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 15: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Scalable

Tested at Google-scale.Deploy everywhere

Easy

Simplified APIs.Focused on Keras and

eager execution

Powerful

Flexibility and performance.Power to do cutting edge research

and scale to > 1 exaflops

TensorFlow 2.0 Alpha is out

Page 16: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 17: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 18: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

tf.data (Dataset)tf.feature_column

(Transfer Learning)

High-level APIs

Perform Distributed Training(talk @1pm)

E.g. V100

Page 19: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

tf.data (Dataset)tf.feature_column

(Transfer Learning)

High-level APIs

Perform Distributed Training(talk @1pm)

E.g. V100

Page 20: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

DNNClassifier

DNNRegressor

LinearClassifier

LinearRegressor

DNNLinearCombinedClassifier

DNNLinearCombinedRegressor

Premade Estimators

BaselineClassifier

BaselineRegressor

BoostedTreeClassifier

BoostedTreeRegressor

input_fn(Datasets, tf.data)

calls

Built to Distribute and Scale

Page 21: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

estimator =

# Train locally

estimator.train (input_fn=..., ...

estimator.evaluate(input_fn=..., ...)

estimator.predict (input_fn=..., ...)

Premade EstimatorsDatasets

Premade Estimators

LinearRegressor(...)

LinearClassifier(...)

DNNRegressor(...)

DNNClassifier(...)

DNNLinearCombinedRegressor(...)

DNNLinearCombinedClassifier(...)

BaselineRegressor(...)

BaselineClassifier(...)

BoostedTreeRegressor(...)

BoostedTreeClassifier(...)

Datasets

Page 22: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

wide_columns = [ tf.feature_column.bucketized_column( 'age',=[18, 27, 40, 65])]deep_columns = [ tf.feature_column.numeric_column('visits'), tf.feature_column.numeric_column('clicks')]

tf.estimator.DNNLinearCombinedClassifier( linear_feature_columns=wide_columns, dnn_feature_columns=deep_columns, dnn_hidden_units=[100, 75, 50, 25])

Premade Estimator - Wide & Deep

Page 23: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

tf.data (Dataset)tf.feature_column

(Transfer Learning)

Perform Distributed Training

E.g. V100

Page 24: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

tf.keras.layerstf.keras Custom Modelsmodel = tf.keras.models.Sequential([ tf.keras.layers.Flatten(), tf.keras.layers.Dense(512, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax')])model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])

model.fit (dataset, epochs=5)model.evaluate(dataset)model.predict (dataset)

Datasets

Page 25: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

TensorFlow Datasets

● audio○ "nsynth"

● image○ "celeb_a"○ "cifar10"○ "coco2014"○ "diabetic_retinopathy_detection"○ "imagenet2012"○ "mnist"○ "open_images_v4"

● structured○ "titanic"

● text○ "imdb_reviews"○ "lm1b"○ "squad"

import tensorflow_datasets as tfds

train_ds = tfds.load("imdb_reviews",

split="train",

as_supervised=True)

● translate○ "wmt_translate_ende"○ "wmt_translate_enfr"

● video○ "bair_robot_pushing_small"○ "moving_mnist"○ "starcraft_video"

● 30+ available● Add your own

Page 26: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

● Datasets (tf.data) for the input pipelinea. TensorFlow Datasets is greatb. tf.feature_columns are cool too

● Premade Estimators

● Keras Models (tf.keras)

TensorFlow Summary

Page 27: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

The V-100

And why is it so good @ Machine Learning???

Page 28: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

● High-Level - We look at only parts of the power of GPUs

● Simple Overview - More optimal designs exist

● Reduced Scope - Only considering fully-connected layers, etc

Disclaimer

Page 29: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Strengths of V100● Built for Massively Parallel Computations

● Specific hardware / software to manage Deep Learning Workloads (Tensor Cores, mixed-precision execution, etc)

Page 30: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Strengths of V100● Built for Massively Parallel Computations

● Specific hardware / software to manage Deep Learning Workloads (Tensor Cores, mixed-precision execution, etc)

Tesla SXM V100

● 5376 cores (FP32)

Page 31: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

What are we going to do with 5376 FP32 cores?

My Questions Around the GPU

Page 32: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

What are we going to do with 5376 FP32 cores?"Execute things in parallel"!

The Unsatisfactory Answer

Page 33: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

What are we going to do with 5376 FP32 cores?"Execute things in parallel"!

Yes, but how can we exactly do that for ML Workloads?

Page 34: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

What are we going to do with 5376 FP32 cores?"Execute things in parallel"!

Yes, but how can we exactly do that for ML Workloads?"Hey, that's your job - That's why we're here listening"!

Page 35: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

What are we going to do with 5376 FP32 cores?"Execute things in parallel"!

Yes, but how can we exactly do that for ML Workloads?"Hey, that's your job - That's why we're here listening"!

Alright, let me try to talk about that then

Page 36: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 37: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 38: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

● We may have a huge number of layers● Each layer can have huge number of neurons

--> There may be 100s millions or even billions * and + ops

All knobs are W values that we need to tuneSo that given a certain input, they generate the correct output

Page 39: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

"Matrix Multiplication is

EATING (the computing resources of) THE WORLD"

hi_j = [X0, X1, X2, ...] * [W0, W1, W2, ...]

hi_j = X0*W0 + X1*W1 + X2*W2 + ...

Page 40: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Matmul

Page 41: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Single-threaded Execution

Page 42: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

[

[

*

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 43: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

1*0.1 = 0.1

[

[

*

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 44: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

Prev

1*0.1 = 0.1

0.1

[

[

*

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 45: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

Prev

1*0.1 = 0.1

0.1 + 2*0.1 = 0.3

[

[

*

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 46: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

Prev

1*0.1 = 0.1

0.1 + 2*0.1 = 0.3

.

.

3238.5+255*0.1 = 3264

3264 + 256*0.1 = 3289.6

[

[

*

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 47: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

Prev

1*0.1 = 0.1

0.1 + 2*0.1 = 0.3

.

.

3238.5+255*0.1 = 3264

3264 + 256*0.1 = 3289.6

[

[

*

Single-threaded Execution

256 * t

Single-threaded ExecutionX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 48: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

GPU Execution

Page 49: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

[

[

*

GPU - #1 Multiplication StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 50: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

[

[

*

GPU - #1 Multiplication StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Tesla SXM V100

5376 cores (FP32)

Page 51: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

[

[

*

GPU - #1 Multiplication StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 52: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

X1_mul_vector

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

[

[

*

GPU - #1 Multiplication StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 53: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

X1_mul_vector

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

[

[

*

Multi-threaded Execution

(256 Threads)

t

GPU - #1 Multiplication StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 54: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

X1_mul_vector

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

[

[

*

Multi-threaded Execution

(256 Threads)

t

GPU - #1 What about Summation?X = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 55: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

[

[

*+

++ = h0,0

X1_mul_vector

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

GPU - #2 Summary StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 56: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

X

1

2

.

.

.

256

[

[

W

0.1

0.1

.

.

.

0.1

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

[

[

*

Multi-threaded Execution

(256 Threads)+

++ = h0,0 log 128 = 2

7 * t

X1_mul_vector

1*0.1 = 0.1

2*0.1 = 0.2

.

.

.

256*0.1 = 25.6

GPU - #2 Summary StepX = [1.0, 2.0, ..., 256.0] # Let's say we have 256 input values

W = [0.1, 0.1, ..., 0.1] # Then we need to have 256 weight values

h0,0 = X * W # [1*0.1 + 2*0.1 + ... + 256*0.1] == 32389.6

Page 57: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Single-ThreadedExecution

GPUMulti-Threaded

Execution

1 * t+

7 * t=

256 * t

Comparing - Order of Magnitude (sequences)

Page 58: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Many Knobs to Tune

But the type of calculation we perform is very suited for GPUs

Page 59: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

Summary

● GPUs == Many Threads == Great for ML Workloads

● And now you know how this works

● Fortunately, you don't need to worry about implementation details

Page 60: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will
Page 61: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

61

multi-core CPU

Page 62: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

62

multi-core CPU

GPU

Page 63: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

63

multi-core CPU

GPU

Work needed: NONE (just use a GPU build)

Page 64: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

64

Beyond ThatUse Distribution Strategy API

There's a talk for that(@ 1pm)

Page 65: Getting Started with TensorFlow on GPUs · Getting Started with TensorFlow on GPUs 1 Magnus Hyttsten @MagnusHyttsten + Agenda. An Awkward Social Experiment (that I'm afraid you will

65

You Can...tensorflow.org/learn

TensorFlow Coursescoursera.org/learn/introduction-tensorflow

udacity.com/tensorflow

Distribution Strategiestensorflow.org/alpha/guide/distribute_strategy @MagnusHyttsten