Sign inSign up

seabbs/tidyverse-gpu

By seabbs

Updated over 7 years ago

Adding in GPU acceleration via CUDA to the rocker/tidyverse container

Image
0

851

seabbs/tidyverse-gpu repository overview

tidyverse-gpu

A Docker image based on rocker/tidyverse including GPU support via CUDA. Based on work done by Noam Ross. The Docker image contains xgboost built for GPU's in both R and Python as well as the latest stable release of h2o. If you wanted to use a different version of CUDA to the one currently installed then changethe relevant environment variables in the Dockerfile and rebuild the image.

Usage

Use as rocker/tidyverse but replace all docker commands with nvidia-docker commands (must have installed nvidia-docker on the host system).

  • Pull/Build
docker pull seabbs/tidyverse-gpu
## Or build 
## Clone repo and navigate into the repo in the terminal
docker build . -t tidyverse-gpu
  • Run
nvidia-docker run -d -p 8787:8787 -e USER=tidyverse-gpu -e PASSWORD=tidyverse-gpu --name tidyverse-gpu seabbs/tidyverse-gpu
## Or build 
nvidia-docker run -d -p 8787:8787 -e USER=tidyverse-gpu -e PASSWORD=tidyverse-gpu --name tidyverse-gpu tidyverse-gpu
  • Login: Go to localhost:8787 and sign in using the password and username given with the docker run command

Nvidia Test

Run nvidia-smi in a bash shell. If GPU support is working correctly it should return GPU usage and temperature information.

nvidia-smi

Xgboost GPU Test

If the following runs without errors xgboost is installed and using the GPU.

library(xgboost)
# load data
data(agaricus.train, package = 'xgboost')
data(agaricus.test, package = 'xgboost')
train <- agaricus.train
test <- agaricus.test
# fit model
bst <- xgboost(data = train$data, label = train$label, max_depth = 5, eta = 0.001, nrounds = 100,
               nthread = 2, objective = "binary:logistic", tree_method = "gpu_hist")
# predict
pred <- predict(bst, test$data)

Xgboost via H2O Test

h2o provides a nice interface to xgboost, along with some great tools for hyper-parameter tuning. (Note: This is not an install of h2o4gpu so only h2o.xgboost supports GPU acceleration.)

# Init h2o
library(h2o)
h2o.init()

# Load test data
australia_path <- system.file("extdata", "australia.csv", package = "h2o")
australia <- h2o.uploadFile(path = australia_path)
independent <- c("premax", "salmax","minairtemp", "maxairtemp", "maxsst",
                 "maxsoilmoist", "Max_czcs")
dependent <- "runoffnew"

# Run xgboost without GPU
h2o.xgboost(y = dependent, x = independent, training_frame = australia,
        ntrees = 1000, backend = "cpu")

# Run xgboost with GPU
h2o.xgboost(y = dependent, x = independent, training_frame = australia,
            ntrees = 1000, backend = "gpu")

Tag summary

Content type

Image

Digest

Size

3.3 GB

Last updated

over 7 years ago

docker pull seabbs/tidyverse-gpu