Coder Social home page Coder Social logo

gpu-keras-rstudio's Introduction

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
  1. Run the container with
sudo nvidia-docker run --name deeplearning-r -d -p 8787:8787 -v ~/:/home/rstudio gpu-keras-tidyverse:1.0
  1. In your browser, navigate to http://localhost:8787/

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

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

Known issues

  • While fitting a model if you get an error that looks like TypeError: update() takes from 2 to 3 positional arguments but 4 were give, see this issue. The fix is to run the following from within the container before working with keras.
devtools::install_github('rstudio/keras')
keras::install_keras(tensorflow = 'gpu')
  • If - after running smoothly - an error regarding a .so file (typically, python, CUDA, cudnn libraries are involved) unexpectedly pops up, re-starting the container with sudo nvidia-docker restart deeplearning-r usually resolves it.
  • Legacy versions of nvidia-docker and docker-ce might result in "Rstudio initialization error : Could not connect to service." Updating nvidia-docker using the instructions here is highly recommended.

Notes

  • once done with a session, stop the container with nvidia-docker stop deeplearning-r.
  • to start a session, nvidia-docker start deeplearning-r and navigate to http://localhost:8787/

gpu-keras-rstudio's People

Contributors

alperyilmaz avatar pbhogale avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.