Skip to content

Commit 20407da

Browse files
committed
🚧
1 parent 7ee2006 commit 20407da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+360
-2213
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: GPU Image
2+
on:
3+
workflow_dispatch: null
4+
push:
5+
paths:
6+
- Dockerfile.gpu
7+
- rl-env.yml
8+
- spatial-env.yml
9+
- jupyter-ai.yml
10+
- install.r
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions: write-all
15+
steps:
16+
# For biggish images, github actions runs out of disk space.
17+
# So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use
18+
# https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150
19+
# and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104
20+
# This gives us a total of about 52G of free space, which should be enough for now
21+
- name: cleanup disk space
22+
run: |
23+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
24+
df -h
25+
- uses: actions/checkout@v3
26+
- name: Login to GitHub Container Registry
27+
if: github.repository == 'rocker-org/ml'
28+
uses: docker/login-action@v1
29+
with:
30+
registry: ghcr.io
31+
username: ${{github.actor}}
32+
password: ${{secrets.GITHUB_TOKEN}}
33+
- name: Build the Docker image
34+
if: github.repository == 'rocker-org/ml'
35+
run: docker build images/ --no-cache -f images/Dockerfile.cuda --tag ghcr.io/rocker/cuda:latest
36+
- name: Publish
37+
if: github.repository == 'rocker-org/ml'
38+
run: docker push ghcr.io/rocker/cuda:latest
39+

.github/workflows/docker-image.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docker Image CI
2+
on:
3+
workflow_dispatch: null
4+
push:
5+
paths: ['images/Dockerfile', 'images/install.r', 'images/rl-env.yml', 'images/spatial-env.yml', 'images/jupyter-ai.yml']
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions: write-all
10+
steps:
11+
# For biggish images, github actions runs out of disk space.
12+
# So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use
13+
# https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150
14+
# and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104
15+
# This gives us a total of about 52G of free space, which should be enough for now
16+
- name: cleanup disk space
17+
run: |
18+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
19+
df -h
20+
- uses: actions/checkout@v3
21+
- name: Login to GitHub Container Registry
22+
if: github.repository == 'boettiger-lab/k8s'
23+
uses: docker/login-action@v1
24+
with:
25+
registry: ghcr.io
26+
username: ${{github.actor}}
27+
password: ${{secrets.GITHUB_TOKEN}}
28+
- name: Build the Docker image
29+
if: github.repository == 'boettiger-lab/k8s'
30+
run: docker build images/ --tag ghcr.io/boettiger-lab/k8s:latest
31+
- name: Publish
32+
if: github.repository == 'boettiger-lab/k8s'
33+
run: docker push ghcr.io/boettiger-lab/k8s:latest
34+

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG BASE=quay.io/jupyter/minimal-notebook:ubuntu-24.04
2+
FROM $BASE
3+
4+
# Make code-server extensions etc persist to container, not hub
5+
ENV XDG_DATA_HOME=/opt/share
6+
7+
USER root
8+
# code-server (VSCode)
9+
RUN curl -fsSL https://code-server.dev/install.sh | sh && rm -rf .cache
10+
11+
# apt utilities, code-server setup
12+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_utilities.sh | bash
13+
14+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_r.sh | bash
15+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_rstudio.sh | bash
16+
17+
## Add rstudio's binaries to path for quarto
18+
ENV PATH=$PATH:/usr/lib/rstudio-server/bin/quarto/bin
19+
20+
## switch non-root users from BSPM to r-universe if no sudo
21+
COPY Rprofile /usr/lib/R/etc/Rprofile.site
22+
23+
# When run as root, install.r automagically handles any necessary apt-gets
24+
COPY install.r install.r
25+
RUN Rscript install.r
26+
27+
USER ${NB_USER}
28+
29+
COPY vscode-extensions.txt vscode-extensions.txt
30+
RUN xargs -n 1 code-server --install-extension < vscode-extensions.txt
31+
32+
COPY environment.yml environment.yml
33+
RUN conda update --all --solver=classic -n base -c conda-forge conda && \
34+
conda env update --file environment.yml
35+

Dockerfile.cuda

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG BASE=quay.io/jupyter/pytorch-notebook:cuda12-ubuntu-24.04
2+
FROM $BASE
3+
4+
# Make code-server extensions etc persist to container, not hub
5+
ENV XDG_DATA_HOME=/opt/share
6+
7+
USER root
8+
# code-server (VSCode)
9+
RUN curl -fsSL https://code-server.dev/install.sh | sh && rm -rf .cache
10+
11+
# apt utilities, code-server setup
12+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_utilities.sh | bash
13+
14+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_r.sh | bash
15+
RUN curl -s https://raw.githubusercontent.com/rocker-org/ml/refs/heads/main/install_rstudio.sh | bash
16+
17+
## Add rstudio's binaries to path for quarto
18+
ENV PATH=$PATH:/usr/lib/rstudio-server/bin/quarto/bin
19+
20+
## switch non-root users from BSPM to r-universe if no sudo
21+
COPY Rprofile /usr/lib/R/etc/Rprofile.site
22+
23+
# When run as root, install.r automagically handles any necessary apt-gets
24+
COPY install.r install.r
25+
RUN Rscript install.r
26+
27+
USER ${NB_USER}
28+
29+
COPY vscode-extensions.txt vscode-extensions.txt
30+
RUN xargs -n 1 code-server --install-extension < vscode-extensions.txt
31+
32+
COPY environment.yml environment.yml
33+
RUN conda update --all --solver=classic -n base -c conda-forge conda && \
34+
conda env update --file environment.yml
35+

README.md

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,3 @@
11
# Rocker stack for Machine Learning in R
22

3-
This repository contains images for machine learning and GPU-based computation in R. **EDIT** Dockerfiles are now built in modular build system at https://github.com/rocker-org/rocker-versioned2 . This repo remains for documentation around the ML part of the stack.
4-
5-
6-
7-
8-
The dependency stack looks like so:
9-
10-
```
11-
-| rocker/cuda
12-
-| rocker/ml
13-
-| rocker/ml-verse
14-
```
15-
16-
All three are CUDA compatible and will optionally take R version tags (`rocker/ml:4.0.5`) with the option of additional trailing CUDA version tag (e.g. `rocker/ml:4.0.5-cuda10.1`).
17-
18-
19-
## Quick start
20-
21-
**Note: GPU use requires [nvidia-docker](https://github.com/NVIDIA/nvidia-docker/)** runtime to run!
22-
23-
Run a bash shell or R command line:
24-
25-
```
26-
# CPU-only
27-
docker run --rm -ti rocker/ml R
28-
# Machines with nvidia-docker and GPU support
29-
docker run --gpus all --rm -ti rocker/ml R
30-
```
31-
32-
Or run in RStudio instance:
33-
34-
```
35-
docker run --gpus all -e PASSWORD=mu -p 8787:8787 rocker/ml
36-
```
37-
38-
39-
## Tags
40-
41-
See [current `ml` tags](https://hub.docker.com/r/rocker/ml/tags?page=1&ordering=last_updated)
42-
See [current `ml-verse` tags](https://hub.docker.com/r/rocker/ml-verse/tags?page=1&ordering=last_updated)
43-
44-
45-
## Python versions and virtualenvs
46-
47-
The ML images configure a default python virtualenv using the Ubuntu system python (3.8.5 for current Ubuntu 20.04 LTS), see [install_python.sh](https://github.com/rocker-org/rocker-versioned2/blob/master/scripts/install_python.sh). This virtualenv is user-writable and the default detected by `reticulate` (using `WORKON_HOME` and `PYTHON_VENV_PATH` variables).
48-
49-
Images also configure [pipenv](https://github.com/pypa/pipenv) with [pyenv](https://github.com/pyenv/pyenv) by default. This makes it very easy to manage projects that require specific versions of Python as well as specific python modules. For instance, a project using the popular `[greta](https://greta-stats.org/)` package for GPU-accelerated Bayesian inference needs Tensorflow 1.x, which requires Python <= 3.7, might do:
50-
51-
```bash
52-
pipenv --python 3.7
53-
```
54-
55-
In the bash terminal to set up a pipenv-managed virtualenv in the working directory using Python 3.7. Then in R we can activate this virtualenv
56-
57-
```r
58-
venv <- system("pipenv --venv", inter = TRUE)
59-
reticulate::use_virtualenv(venv, required = TRUE)
60-
```
61-
62-
We can now install tensorflow version needed, e.g.
63-
64-
```r
65-
install.packages("tensorflow")
66-
tensorflow::install_tensorflow(version="1.14.0-gpu", extra_packages="tensorflow-probability==0.7.0")
67-
```
68-
69-
70-
71-
## Notes
72-
73-
All images are based on the current Ubuntu LTS (ubuntu 20.04) and based on the official [NVIDIA CUDA docker build recipes](https://gitlab.com/nvidia/container-images/cuda/)
74-
75-
**PLEASE NOTE**: older images, `rocker/ml-gpu`, `rocker/tensorflow` and `rocker/tensorflow-gpu`, built with cuda 9.0, are deprecated and no longer supported.
76-
77-
3+
This repository contains images for machine learning and GPU-based computation in R.

Rprofile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Based on Jeroen's config:
2+
# https://github.com/r-universe-org/base-image/blob/f20ec9fc6f51ef8a89aad489206a43790bd9bf77/Rprofile
3+
4+
5+
6+
local({
7+
8+
has_sudo <- function() {
9+
system("sudo -n true", intern = TRUE) == 0
10+
}
11+
12+
# Only use Runiverse if we don't have sudo
13+
if (!has_sudo()) {
14+
15+
rver <- getRversion()
16+
distro <- system2('lsb_release', '-sc', stdout = TRUE)
17+
options(HTTPUserAgent = sprintf("R/%s R (%s)", rver, paste(rver, R.version$platform, R.version$arch, R.version$os)))
18+
options(repos = c(CRAN = sprintf("https://packagemanager.rstudio.com/all/__linux__/%s/latest", distro)))
19+
20+
# Enable BioConductor repos
21+
utils::setRepositories(ind = 1:4, addURLs = c(fallback = "https://cloud.r-project.org"))
22+
23+
# Enable universe repo(s)
24+
my_universe <- Sys.getenv("MY_UNIVERSE", "https://cran.r-universe.dev")
25+
if(nchar(my_universe)){
26+
my_repos <- trimws(strsplit(my_universe, ';')[[1]])
27+
binaries <- sprintf('%s/bin/linux/%s/%s', my_repos[1], distro, substr(rver, 1, 3))
28+
options(repos = c(binaries = binaries, universe = my_repos, getOption("repos")))
29+
}
30+
31+
}
32+
# Other settings
33+
options(crayon.enabled = TRUE)
34+
Sys.unsetenv(c("CI", "GITHUB_ACTIONS"))
35+
36+
# Dummy token for API limits
37+
if(is.na(Sys.getenv("GITHUB_PAT", NA))){
38+
dummy <- c('ghp_SXg', 'LNM', 'Tu4cnal', 'tdqkZtBojc3s563G', 'iqv')
39+
Sys.setenv(GITHUB_PAT = paste(dummy, collapse = 'e'))
40+
}
41+
})
42+

deprecated/Makefile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)