We are going to mess around with some of the R gpu packages using our eGPU Rig. Look here for how to set up RStudio and then use the gpuR, gputools and keras/tensorflow packages against an eGPU.
Setup
0. Prerequisites
Setup your eGPU as described at NUC with eGPU – a Big Little ML Rig. Smoketest your rig to verify basic CUDA functionality by issuing commands such as.
$ nvidia-smi $ nvcc -V $ gcc -v $ cd ~/MLOps/NVIDIA_CUDA-9.0_Samples/bin/x86_64/linux/release $ ./deviceQuery $ ~/MLOps/cudnn_samples_v7/mnistCUDNN $ ./mnistCUDNN $ env | grep LD_LIBRARY_PATH LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/lib/nvidia-384: $ env | grep PATH PATH=/usr/local/cuda-9.0/bin:/usr/lib/nvidia-384/bin:/usr/lib/nvidia-384:...
1. RStudio Desktop
Let’s try out some R GPU libraries, but we are going to need RStudio first. Locate then download your RStudio distribution at https://www.rstudio.com/products/rstudio/download/#download . For Ubuntu 17.04, I also needed to download some additional packages and then proceed as follows.
$ wget http://ftp.jp.debian.org/debian/pool/main/g/gstreamer0.10/libgstreamer0.10-0_0.10.36-1.5_amd64.deb $ wget http://ftp.jp.debian.org/debian/pool/main/g/gst-plugins-base0.10/libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb $ apt-get install -f $ sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb $ sudo dpkg -i libgstreamer0.10-0_0.10.36-1.5_amd64.deb $ sudo apt install libjpeg62 libedit2 $ sudo gdebi -n rstudio-1.1.383-amd64.deb
2. R gpuR Package
Launch RStudio and install the gpuR package. Copy/paste in the sample sample at https://bitbucket.org/emergile/MLOps/src/master/gpu/gpuR.R and verify it works. Install any other R packages as required, e.g. ggplot2. Looking good?
2. R gputools Package
Next we take the gputools R package for a spin. Follow the instructions at https://goatoftheplague.com/2016/12/08/installing-r-package-gputools-and-cuda-8-0-on-ubuntu-16-04/ to install this package (e.g. to overcome the R.h include file issue). Install the source modified package as follows:
> install.packages("~/Downloads/gputools_1.1_new.tar.gz", repos = NULL, type = "source")
Once installed try out the sample gputools R script at https://bitbucket.org/emergile/MLOps/src/master/gpu/gputools.R
3. R Keras Package using Tensorsoft
First we need to setup tensorflow and python as described towards the end of NUC with eGPU – a Big Little ML Rig . Now from RStudio use the Console window to install Keras as follows:
> install.packages('Rcpp') > install.packages('devtools') > devtools::install_github("rstudio/reticulate") > devtools::install_github("rstudio/keras") > library("keras") > install_keras(tensorflow = "gpu")
You are now ready to test drive a few sample scripts:
- https://bitbucket.org/emergile/MLOps/blob/master/gpu/Keras1.R
- https://bitbucket.org/emergile/MLOps/src/master/gpu/Keras2.R
- https://raw.githubusercontent.com/rstudio/keras/master/vignettes/examples/lstm_text_generation.R
Other gpu R Packages Attempted
- cudaBayesreg
- install fails with -lRmath related issue
- gmatrix
- install fails with gcc version related issue
- permGPU
- install fails with Biobase availability related issue
- gpuRcuda
- R CMD INSTALL fails with packaging issue
- rpud
- Requires license file
Resources
- https://secure.hosting.vt.edu/www.arc.vt.edu/wp-content/uploads/2017/04/GPU_R_Workshop_2017_slidy.html
- https://github.com/berkeley-scf/gpu-workshop-2016
- http://www.parallelr.com/r-gpu-programming-for-all-with-gpur/
- http://www.parallelr.com/slides/ParallelR-Accelerating%20R%20Applications%20with%20CUDA.pdf
- http://lorenabarba.com/gpuatbu/Program_files/Cruz_gpuComputing09.pdf
- http://dirk.eddelbuettel.com/papers/useR2010hpcTutorialHandout.pdf
- https://www.udacity.com/course/intro-to-parallel-programming–cs344
- https://keras.rstudio.com
- https://keras.rstudio.com/articles/examples/
- https://medium.com/towards-data-science/how-to-implement-deep-learning-in-r-using-keras-and-tensorflow-82d135ae4889