SlideShare a Scribd company logo
From Zero to Hero
ALL YOU NEED TO DO SERIOUS DEEP LEARNING STUFF IN R
Agenda
• About Me
• How I use R/RStudio/(Nvidia)Docker
• Image recognition with R and Keras
Kai Lichtenberg, 33
Machine Learning Deep Learning
Sales Engineer
Mechanical
Engineer
Data Scientist
MSc
Sales Engineering & Product
Management
BSc
Sales Engineering & Product
Management
PhD @ Bosch
MSc
Mechanical Engineering
BSc
Mechanical Engineering
Working student
Gearbox
Development
Advanced Engineering
Transmission Units
Advanced Engineering
Connectivity Solutions
Founder, Data Scientist,
Accountant, Office
Manager, Janitor, …
Classic Stuff
Language Journey
TODAY
Quantum Computing
Q#
Some Projects
• Modeling reliability of equipment with high dimensional data (PhD)
• Non-linear exogenous autoregression (neural nets) to predict temperature
• Various production datasets, e.g. high pressure diesel pump and injector
• Who’s driving the machine? Driver classification and profiling
• Condition monitoring via acceleration and acoustic signals
• Customer churn prediction
• Image recognition with deep neural nets
• Blogging @Bosch
The Toolbox
NO CRAFTSMANSHIP WITHOUT GOOD TOOLS!
How my Dev Environment looked like
• Installed on the same system I use for office, browsing, etc.
• Pretty big stack with numerous packages, IDE’s, dependen-
cies, drivers, venvs, environment variables, …
• Especially the Keras->TensorFlow->cuDNN toolchain is tricky
• Takes hours to set up and just seconds to mess up
• I tend to fiddle around and break things :-)
• Needs to be installed on my laptop and my workstation (and
behave the same)
How I want my Dev Environment
• Very easy to install
• Portable to any Linux
• GPU support!
• No big overhead, use of native system resources
• No fiddling, tweaking an tuning
• All my beloved packages and tools
No cloud services! Only a container registry
Sneak Peek
#Docker CE
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce
usermod -a -G docker $USER
# Add the package repositories for nvidia docker
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | 
tee /etc/apt/sources.list.d/nvidia-docker.list
apt-get update
# Install nvidia-docker2 and reload the Docker daemon
apt-get install -y nvidia-docker2
pkill -SIGHUP dockerd
#Log into the nvidia repo and get tensorflow python 3
docker login nvcr.io
docker pull nvcr.io/nvidia/tensorflow:18.02-py3
#Clone Repo and build images
git clone https://github.com/KaiLicht/DataScience_Toolbox
cd DataScience_Toolbox/dockerfiles/Rbase_keras_tf
docker build -t kailicht/Rbase_keras_tf .
cd DataScience_Toolbox/dockerfiles/RStudio_deeplearning
docker build -t kailicht/rstudio_deeplearning .
cd DataScience_Toolbox/dockerfiles/My_Rstudio
docker build -t kailicht/myrstudio:1.0 .
No need to copy! I’m going to publish a
blogpost on how to create this stuff from
scratch and link it in the meetup group.
What is Docker?
Server
Host OS
Hypervisor
Guest OS
Bins/Libs
App A
Guest OS
Bins/Libs
App B
Server
Host OS
Docker Engine
Bins/Libs
App A
Bins/Libs
App B
Virtualization (VM’s) Isolation (Container)
Server
Host OS
Docker Engine
Bins/Libs
App A
Bins/Libs
App B
Container with GPU
GPU GPU GPU
CUDA Driver
CUDA toolkit CUDA toolkit
• No shared resources
• Complete OS is emulated
• Big overhead
• Not really suited for Data
Science environments
• Shared resources with host
• Only isolated file system
• Very little overhead
• Perfect for reproducible
Data Science
• Containers with GPU
passthrough
• Nvidia offers preconfigured
and optimized images for
different use cases (e.g. a
python-TensorFlow image)
See for yourself!
How to make a docker image
FROM ubuntu:16.04
MAINTAINER Kai Lichtenberg <kai@sentin.ai>
# Set a default user.
RUN useradd docker 
&& mkdir /home/docker 
&& chown docker:docker /home/docker 
&& addgroup docker staff
RUN apt-get update 
&& apt-get install -y --no-install-recommends 
ed 
locales 
vim-tiny 
fonts-texgyre 
gnupg2 
libcurl4-openssl-dev 
libssl-dev 
libssh2-1-dev 
sudo 
&& rm -rf /var/lib/apt/lists/*
dockerfile:
kai@XPS15:~$ docker build -t my_ubuntu:1.0 .
Building the image:
What is happening?
• By starting the build process docker first downloads the ubuntu:16.04
base image from dockerhub
• Then it starts the base image and basically parses the commands in the
dockerfile (here: adding a user and installing some stuff with apt-get)
• After everything is done the image is saved with the tag my_ubuntu:1.0
kai@XPS15:~$ docker run –it my_ubuntu:1.0
root@52d676fa5956:/workspace# uname –a
Linux 9b6e2b8f6e53 4.13.0-38-generic #43~16.04.1-Ubuntu SMP
Wed Mar 14 17:48:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Starting the image:
My Rstudio Docker Containers
kailicht/my_rstudio:1.0
Building it in 4 stages • The foundation for this build is the
tensorflow:18.02-py3 image from NVIDIA
• It comes batteries included:
• Ubuntu 16.04 with python 3.5
• NVIDIA CUDA
• cuBLAS (Linear Algebra)
• NCCL (For Multi-GPU usage)
• Horovod Distributed DL Framework
• OpenMPI
• Tensorboard
• TensorRT to optimize deployment
kailicht/rstudio_deeplearning
kailicht/rbase_keras_tf
Base: tensorflow:18.02-py3
Let’s have a look
into the dockerfiles!
0. Get the base image
1. Install R, Keras &TensorFlow for R
2. Install Rstudio and dependencies
3. Customize (Settings, Packages)
kailicht/my_rstudio:1.x 4. Install new packages
Images for different use cases:
• Do Data Science REPL-Work: kailicht/my_rstudio:1.x
• Deploy a shiny app with image recognition: kailicht/rbase_keras_tf
• Deploy a flask microservice with a TensorFlow model: tensorflow:18.02-py3
• …
Hello world!
CLASSIFY HANDWRITTEN DIGITS WITH KERAS FOR R AND OUR BRAND NEW DEV
ENVIRONMENT!
But wait, isn’t python better for Deep Learning?
• No.
• In python and R you only define the neural network!
• All the magic happens in the toolchain.
• It creates the computational graph and performs all the matrix operations needed on
your CUDA enabled GPU.
• Sorry but using R or python for Deep Learning is pretty much like using a GUI
• If you want to deploy a trained network (e.g. as an API) then python is the better choice
• It’s important to differentiate between creating a model and deploying it!
Before we start: The MNIST Data Set
In R:
• The Hello World of Machine Learning
• 70k handwritten digits as 28x28 monochrome pictures
• And off course the class labels (0-9)
btw: this is a tensor! (like
any other matrix or vector)
Before we start: Piping
#Select 3 columns in a data frame
MyDataFrame2 <- select(MyDataFrame1, MyCol1, MyCol2, MyCol3)
#Is the same like:
MyDataFrame2 <- MyDataFrame1 %>%
select(MyCol1, MyCol2, MyCol3)
#Chain it!
MyDataFrame2 <- MyDataFrame1 %>%
select(MyCol1, MyCol2, MyCol3) %>%
filter(MyCol1 <= "SomeValue") %>%
mutate(MyCol4 = MyCol1 / MyCol2) %>%
summarize_all(mean)
Also very neat for operating with tensors flowing through a neural net!
Before we start: The MLP Architecture
Inputs Weights
Sum
Activation
Function
Bias
Symbol:
Input Layer Hidden Layer Output Layer
• The weights and biases are optimized to best fit the data in a process called backpropagation
• There are a lot of (simple) tricks to prevent overfitting (dropout, learning rate decay, …)
• For a more detailed introduction I recommend the 2 hour talk from Martin Görner @ Google
Cloud Next ‘17
But how does it work with a 28x28 picture?
It’s tidy! :)
Let’s code that!
https://cntk.ai/pythondocs/CNTK_103C_MNIST_MultiLayerPerceptron.html
What are we missing?
What are we missing?
• The spatial correlation of the pixel in their 2D space is lost!
• This information is important!  Convolutional Neural Network!
https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#4
ConvNet for MNIST
https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#4
Backup
Cross Entropy
https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#4
A little more complex: Unet

More Related Content

What's hot

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing Landscape
Kernel TLV
 
Cgroups, namespaces and beyond: what are containers made from?
Cgroups, namespaces and beyond: what are containers made from?Cgroups, namespaces and beyond: what are containers made from?
Cgroups, namespaces and beyond: what are containers made from?
Docker, Inc.
 
Make Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance ToolsMake Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance Tools
Kernel TLV
 
Nsq & python worker
Nsq & python workerNsq & python worker
Nsq & python worker
Felinx Lee
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
kawamuray
 
Linux BPF Superpowers
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF Superpowers
Brendan Gregg
 
Kqueue : Generic Event notification
Kqueue : Generic Event notificationKqueue : Generic Event notification
Kqueue : Generic Event notification
Mahendra M
 
GPU Computing for Data Science
GPU Computing for Data Science GPU Computing for Data Science
GPU Computing for Data Science
Domino Data Lab
 
An Updated Performance Comparison of Virtual Machines and Linux Containers
An Updated Performance Comparison of Virtual Machines and Linux ContainersAn Updated Performance Comparison of Virtual Machines and Linux Containers
An Updated Performance Comparison of Virtual Machines and Linux Containers
Kento Aoyama
 
Docker - container and lightweight virtualization
Docker - container and lightweight virtualization Docker - container and lightweight virtualization
Docker - container and lightweight virtualization
Sim Janghoon
 
Stateless Hypervisors at Scale
Stateless Hypervisors at ScaleStateless Hypervisors at Scale
Stateless Hypervisors at Scale
Antony Messerl
 
LISA2010 visualizations
LISA2010 visualizationsLISA2010 visualizations
LISA2010 visualizations
Brendan Gregg
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
Brendan Gregg
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
Max Kleiner
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
Brendan Gregg
 
(1) cpp introducing the_cpp_programming_language
(1) cpp introducing the_cpp_programming_language(1) cpp introducing the_cpp_programming_language
(1) cpp introducing the_cpp_programming_language
Nico Ludwig
 
WTF my container just spawned a shell!
WTF my container just spawned a shell!WTF my container just spawned a shell!
WTF my container just spawned a shell!
Sysdig
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
Keith Wright
 
Using R on High Performance Computers
Using R on High Performance ComputersUsing R on High Performance Computers
Using R on High Performance Computers
Dave Hiltbrand
 

What's hot (20)

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing Landscape
 
Cgroups, namespaces and beyond: what are containers made from?
Cgroups, namespaces and beyond: what are containers made from?Cgroups, namespaces and beyond: what are containers made from?
Cgroups, namespaces and beyond: what are containers made from?
 
Make Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance ToolsMake Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance Tools
 
Nsq & python worker
Nsq & python workerNsq & python worker
Nsq & python worker
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Linux BPF Superpowers
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF Superpowers
 
Kqueue : Generic Event notification
Kqueue : Generic Event notificationKqueue : Generic Event notification
Kqueue : Generic Event notification
 
GPU Computing for Data Science
GPU Computing for Data Science GPU Computing for Data Science
GPU Computing for Data Science
 
An Updated Performance Comparison of Virtual Machines and Linux Containers
An Updated Performance Comparison of Virtual Machines and Linux ContainersAn Updated Performance Comparison of Virtual Machines and Linux Containers
An Updated Performance Comparison of Virtual Machines and Linux Containers
 
Docker - container and lightweight virtualization
Docker - container and lightweight virtualization Docker - container and lightweight virtualization
Docker - container and lightweight virtualization
 
Stateless Hypervisors at Scale
Stateless Hypervisors at ScaleStateless Hypervisors at Scale
Stateless Hypervisors at Scale
 
LISA2010 visualizations
LISA2010 visualizationsLISA2010 visualizations
LISA2010 visualizations
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
maXbox Starter87
maXbox Starter87maXbox Starter87
maXbox Starter87
 
MeetBSD2014 Performance Analysis
MeetBSD2014 Performance AnalysisMeetBSD2014 Performance Analysis
MeetBSD2014 Performance Analysis
 
(1) cpp introducing the_cpp_programming_language
(1) cpp introducing the_cpp_programming_language(1) cpp introducing the_cpp_programming_language
(1) cpp introducing the_cpp_programming_language
 
WTF my container just spawned a shell!
WTF my container just spawned a shell!WTF my container just spawned a shell!
WTF my container just spawned a shell!
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
Using R on High Performance Computers
Using R on High Performance ComputersUsing R on High Performance Computers
Using R on High Performance Computers
 

Similar to From Zero to Hero - All you need to do serious deep learning stuff in R

Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
rkr10
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
Sencha
 
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Hakky St
 
Docker engine - Indroduc
Docker engine - IndroducDocker engine - Indroduc
Docker engine - Indroduc
Al Gifari
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
Ambassador Labs
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Jérôme Petazzoni
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
Anton Egorov
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
Jérôme Petazzoni
 
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Valeriy Kravchuk
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
Eric Smalling
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Ambassador Labs
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Development
allingeek
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and ContainersDocker, Inc.
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
Sabyrzhan Tynybayev
 
OpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyOpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon Valley
Ganesan Narayanasamy
 
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUsScalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Indrajit Poddar
 

Similar to From Zero to Hero - All you need to do serious deep learning stuff in R (20)

Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
 
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
Creating basic workflows as Jupyter Notebooks to use Cytoscape programmatically.
 
Docker engine - Indroduc
Docker engine - IndroducDocker engine - Indroduc
Docker engine - Indroduc
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
 
Deliver Python Apps with Docker
Deliver Python Apps with DockerDeliver Python Apps with Docker
Deliver Python Apps with Docker
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
 
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Development
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
 
ABCs of docker
ABCs of dockerABCs of docker
ABCs of docker
 
OpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon ValleyOpenPOWER Workshop in Silicon Valley
OpenPOWER Workshop in Silicon Valley
 
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUsScalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
 

Recently uploaded

一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 

Recently uploaded (20)

一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 

From Zero to Hero - All you need to do serious deep learning stuff in R

  • 1. From Zero to Hero ALL YOU NEED TO DO SERIOUS DEEP LEARNING STUFF IN R
  • 2. Agenda • About Me • How I use R/RStudio/(Nvidia)Docker • Image recognition with R and Keras
  • 3. Kai Lichtenberg, 33 Machine Learning Deep Learning Sales Engineer Mechanical Engineer Data Scientist MSc Sales Engineering & Product Management BSc Sales Engineering & Product Management PhD @ Bosch MSc Mechanical Engineering BSc Mechanical Engineering Working student Gearbox Development Advanced Engineering Transmission Units Advanced Engineering Connectivity Solutions Founder, Data Scientist, Accountant, Office Manager, Janitor, … Classic Stuff Language Journey TODAY Quantum Computing Q#
  • 4. Some Projects • Modeling reliability of equipment with high dimensional data (PhD) • Non-linear exogenous autoregression (neural nets) to predict temperature • Various production datasets, e.g. high pressure diesel pump and injector • Who’s driving the machine? Driver classification and profiling • Condition monitoring via acceleration and acoustic signals • Customer churn prediction • Image recognition with deep neural nets • Blogging @Bosch
  • 5. The Toolbox NO CRAFTSMANSHIP WITHOUT GOOD TOOLS!
  • 6. How my Dev Environment looked like • Installed on the same system I use for office, browsing, etc. • Pretty big stack with numerous packages, IDE’s, dependen- cies, drivers, venvs, environment variables, … • Especially the Keras->TensorFlow->cuDNN toolchain is tricky • Takes hours to set up and just seconds to mess up • I tend to fiddle around and break things :-) • Needs to be installed on my laptop and my workstation (and behave the same)
  • 7. How I want my Dev Environment • Very easy to install • Portable to any Linux • GPU support! • No big overhead, use of native system resources • No fiddling, tweaking an tuning • All my beloved packages and tools No cloud services! Only a container registry
  • 8. Sneak Peek #Docker CE apt-get update apt-get install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" apt-get update apt-get install docker-ce usermod -a -G docker $USER # Add the package repositories for nvidia docker curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list apt-get update # Install nvidia-docker2 and reload the Docker daemon apt-get install -y nvidia-docker2 pkill -SIGHUP dockerd #Log into the nvidia repo and get tensorflow python 3 docker login nvcr.io docker pull nvcr.io/nvidia/tensorflow:18.02-py3 #Clone Repo and build images git clone https://github.com/KaiLicht/DataScience_Toolbox cd DataScience_Toolbox/dockerfiles/Rbase_keras_tf docker build -t kailicht/Rbase_keras_tf . cd DataScience_Toolbox/dockerfiles/RStudio_deeplearning docker build -t kailicht/rstudio_deeplearning . cd DataScience_Toolbox/dockerfiles/My_Rstudio docker build -t kailicht/myrstudio:1.0 . No need to copy! I’m going to publish a blogpost on how to create this stuff from scratch and link it in the meetup group.
  • 9. What is Docker? Server Host OS Hypervisor Guest OS Bins/Libs App A Guest OS Bins/Libs App B Server Host OS Docker Engine Bins/Libs App A Bins/Libs App B Virtualization (VM’s) Isolation (Container) Server Host OS Docker Engine Bins/Libs App A Bins/Libs App B Container with GPU GPU GPU GPU CUDA Driver CUDA toolkit CUDA toolkit • No shared resources • Complete OS is emulated • Big overhead • Not really suited for Data Science environments • Shared resources with host • Only isolated file system • Very little overhead • Perfect for reproducible Data Science • Containers with GPU passthrough • Nvidia offers preconfigured and optimized images for different use cases (e.g. a python-TensorFlow image) See for yourself!
  • 10. How to make a docker image FROM ubuntu:16.04 MAINTAINER Kai Lichtenberg <kai@sentin.ai> # Set a default user. RUN useradd docker && mkdir /home/docker && chown docker:docker /home/docker && addgroup docker staff RUN apt-get update && apt-get install -y --no-install-recommends ed locales vim-tiny fonts-texgyre gnupg2 libcurl4-openssl-dev libssl-dev libssh2-1-dev sudo && rm -rf /var/lib/apt/lists/* dockerfile: kai@XPS15:~$ docker build -t my_ubuntu:1.0 . Building the image: What is happening? • By starting the build process docker first downloads the ubuntu:16.04 base image from dockerhub • Then it starts the base image and basically parses the commands in the dockerfile (here: adding a user and installing some stuff with apt-get) • After everything is done the image is saved with the tag my_ubuntu:1.0 kai@XPS15:~$ docker run –it my_ubuntu:1.0 root@52d676fa5956:/workspace# uname –a Linux 9b6e2b8f6e53 4.13.0-38-generic #43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Starting the image:
  • 11. My Rstudio Docker Containers kailicht/my_rstudio:1.0 Building it in 4 stages • The foundation for this build is the tensorflow:18.02-py3 image from NVIDIA • It comes batteries included: • Ubuntu 16.04 with python 3.5 • NVIDIA CUDA • cuBLAS (Linear Algebra) • NCCL (For Multi-GPU usage) • Horovod Distributed DL Framework • OpenMPI • Tensorboard • TensorRT to optimize deployment kailicht/rstudio_deeplearning kailicht/rbase_keras_tf Base: tensorflow:18.02-py3 Let’s have a look into the dockerfiles! 0. Get the base image 1. Install R, Keras &TensorFlow for R 2. Install Rstudio and dependencies 3. Customize (Settings, Packages) kailicht/my_rstudio:1.x 4. Install new packages Images for different use cases: • Do Data Science REPL-Work: kailicht/my_rstudio:1.x • Deploy a shiny app with image recognition: kailicht/rbase_keras_tf • Deploy a flask microservice with a TensorFlow model: tensorflow:18.02-py3 • …
  • 12. Hello world! CLASSIFY HANDWRITTEN DIGITS WITH KERAS FOR R AND OUR BRAND NEW DEV ENVIRONMENT!
  • 13. But wait, isn’t python better for Deep Learning? • No. • In python and R you only define the neural network! • All the magic happens in the toolchain. • It creates the computational graph and performs all the matrix operations needed on your CUDA enabled GPU. • Sorry but using R or python for Deep Learning is pretty much like using a GUI • If you want to deploy a trained network (e.g. as an API) then python is the better choice • It’s important to differentiate between creating a model and deploying it!
  • 14. Before we start: The MNIST Data Set In R: • The Hello World of Machine Learning • 70k handwritten digits as 28x28 monochrome pictures • And off course the class labels (0-9) btw: this is a tensor! (like any other matrix or vector)
  • 15. Before we start: Piping #Select 3 columns in a data frame MyDataFrame2 <- select(MyDataFrame1, MyCol1, MyCol2, MyCol3) #Is the same like: MyDataFrame2 <- MyDataFrame1 %>% select(MyCol1, MyCol2, MyCol3) #Chain it! MyDataFrame2 <- MyDataFrame1 %>% select(MyCol1, MyCol2, MyCol3) %>% filter(MyCol1 <= "SomeValue") %>% mutate(MyCol4 = MyCol1 / MyCol2) %>% summarize_all(mean) Also very neat for operating with tensors flowing through a neural net!
  • 16. Before we start: The MLP Architecture Inputs Weights Sum Activation Function Bias Symbol: Input Layer Hidden Layer Output Layer • The weights and biases are optimized to best fit the data in a process called backpropagation • There are a lot of (simple) tricks to prevent overfitting (dropout, learning rate decay, …) • For a more detailed introduction I recommend the 2 hour talk from Martin Görner @ Google Cloud Next ‘17
  • 17. But how does it work with a 28x28 picture? It’s tidy! :) Let’s code that! https://cntk.ai/pythondocs/CNTK_103C_MNIST_MultiLayerPerceptron.html
  • 18. What are we missing?
  • 19. What are we missing? • The spatial correlation of the pixel in their 2D space is lost! • This information is important!  Convolutional Neural Network! https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#4
  • 23. A little more complex: Unet