pbhogale / gpu-keras-rstudio

Dockerfile
MIT License
16 stars 5 forks source link

Dockerfile for GPU enabled rstudio server with keras+tensorflow

Coaxing Rstudio+Keras+tensorflow to use your local GPU can be tricky. This is one solution to that problem.

Disclaimer : The Dockerfile needs re-factoring to be more efficient during the build process. Inspired by https://github.com/rocker-org/ml/.

This repo contains a plausible (tested on NVIDIA GeForce 755M) docker container with rstudio server and the tidyverse and keras+tensorflow built on top of nvidia/cuda:9.0-cudnn7-runtime. The objective is to be able to run the code from the Deep learning in R (by F. Chollet) book given an NVIDIA GPU with drivers installed. The Docker container will install the CUDA and cudnn libraries needed.

There is also an .Rmd file with some code snippets from the book, so that you can test if the setup works.

See this, this and this for other approaches and discussions.

Pre-requisites

  1. NVIDIA gpu. If you don't need to run on the GPU, you are better off just running code in your local RStudio or the excellent verse container from the rocker project. If you are using linux and are unsure if your NVIDIA gpu is being used, see this.

  2. docker. If you have not updated your docker installation in a while, or don't have one, you can get the latest version of docker-ce for your OS from here.

  3. nvidia-docker. This is needed to be able to run docker containers with the nvidia CUDA cudnn backends we need. Follow the installation instructions here.

Getting started

  1. Clone this repo and from the command line, switch to the repo directory.

  2. From the repo directory run the following (and then get a coffee. Typically, the build process will take some time) :

    sudo nvidia-docker build --rm -t gpu-keras-tidyverse:1.0 gpu-keras-tidyverse
  3. Run the container with

    sudo nvidia-docker run --name deeplearning-r -d -p 8787:8787 -v ~/:/home/rstudio gpu-keras-tidyverse:1.0
  4. In your browser, navigate to http://localhost:8787/

  5. Login with rstudio:rstudio (or go for easter egg hunt in Dockerfile for the correct password.. It might be "rstudioTheLegendOfZelda" ;)

  6. Open the keras_playground.Rmd notebook from the repo directory and try it out !

Known issues

Notes