Skip to content

Commit 71c4f2f

Browse files
authored
Merge pull request #26 from rocker-org/ubuntu
Ubuntu-based image
2 parents e2f7433 + a08d32d commit 71c4f2f

19 files changed

+959
-0
lines changed

ubuntu/10.0/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM nvidia/cuda:10.0-cudnn7-devel
2+
3+
LABEL org.label-schema.license="GPL-2.0" \
4+
org.label-schema.vcs-url="https://github.com/rocker-org/rocker-versioned" \
5+
org.label-schema.vendor="Rocker Project" \
6+
maintainer="Carl Boettiger <[email protected]>"
7+
8+
ENV TERM=xterm
9+
10+
## cuda:9.0 is xenial, cuda:10.0 is bionic
11+
ARG UBUNTU_VERSION=bionic
12+
ARG R_HOME=/usr/lib/R
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
15+
16+
#ENV R_VERSION=${R_VERSION:-3.6.0}
17+
ENV LC_ALL=en_US.UTF-8
18+
ENV LANG=en_US.UTF-8
19+
COPY install_R.sh /tmp/install_R.sh
20+
RUN . /tmp/install_R.sh
21+
22+
23+
24+
COPY install_rstudio.sh /tmp/install_rstudio.sh
25+
#RUN . /tmp/install_rstudio.sh
26+
COPY userconf.sh /etc/cont-init.d/userconf
27+
EXPOSE 8787
28+
#CMD ["/init"]
29+
30+
31+
32+
COPY install_tidyverse.sh /tmp/install_tidyverse.sh
33+
#RUN . /tmp/install_tidyverse.sh
34+
35+
36+
37+
COPY install_verse.sh /tmp/install_verse.sh
38+
#RUN . /tmp/install_verse.sh
39+
40+
41+
42+
## Use Configure CUDA for R, use NVidia libs for BLAS
43+
ENV CUDA_HOME=/usr/local/cuda
44+
ENV PATH=$PATH:$CUDA_HOME/bin
45+
ENV LD_LIBRARY_PATH=$CUDA_HOME/lib64/libnvblas.so:$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64
46+
ENV NVBLAS_CONFIG_FILE=/etc/nvblas.conf
47+
COPY config_R_cuda.sh /tmp/config_R_cuda.sh
48+
RUN . /tmp/config_R_cuda.sh
49+
50+
51+
ENV PYTHON_VENV_PATH=/opt/venv
52+
ENV RETICULATE_PYTHON_ENV=$PYTHON_VENV_PATH
53+
ENV PATH=${PYTHON_VENV_PATH}/bin:${PATH}
54+
COPY install_python.sh /tmp/install_python.sh
55+
RUN . /tmp/install_python.sh
56+
57+
58+
59+
COPY install_tensorflow-gpu.sh /tmp/install_tensorflow-gpu.sh
60+
#RUN . /tmp/install_tensorflow-gpu.sh
61+

ubuntu/10.0/config_R_cuda.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
## CUDA environmental variables configuration for RStudio
6+
7+
## cli R inherits these, but RStudio needs to have these set in as follows:
8+
## (From https://tensorflow.rstudio.com/tools/local_gpu.html#environment-variables)
9+
echo "\n\
10+
\nCUDA_HOME=$CUDA_HOME\
11+
\nPATH=$PATH" >> ${R_HOME}/etc/Renviron
12+
13+
if test -f /etc/rstudio/rserver.conf; then
14+
echo "rsession-ld-library-path=$LD_LIBRARY_PATH" >> /etc/rstudio/rserver.conf
15+
fi
16+
17+
touch /var/log/nvblas.log && chown :staff /var/log/nvblas.log
18+
19+
## Configure R & RStudio to use drop-in CUDA blas
20+
## Allow R to use CUDA for BLAS, with fallback on openblas
21+
echo "\nNVBLAS_LOGFILE /var/log/nvblas.log \
22+
\nNVBLAS_CPU_BLAS_LIB /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 \
23+
\nNVBLAS_GPU_LIST ALL" > /etc/nvblas.conf
24+
25+
echo "NVBLAS_CONFIG_FILE=$NVBLAS_CONFIG_FILE" >> ${R_HOME}/etc/Renviron
26+
27+
28+
## We don't want to set LD_PRELOAD globally
29+
##ENV LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so
30+
#
31+
### Instead, we will set it before calling R, Rscript, or RStudio:
32+
#mv /usr/bin/R /usr/bin/R_
33+
#mv /usr/bin/Rscript /usr/bin/Rscript_
34+
#
35+
#echo '\#!/bin/sh \
36+
# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/R_ "$@"' \
37+
# > /usr/bin/R && \
38+
# chmod +x /usr/bin/R && \
39+
# echo '#!/bin/sh \
40+
# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/Rscript_ "$@"' \
41+
# > /usr/bin/Rscript && \
42+
# chmod +x /usr/bin/Rscript
43+
#
44+
#echo '#!/usr/bin/with-contenv bash \
45+
# \n## load /etc/environment vars first: \
46+
# \n for line in \$( cat /etc/environment ) ; do export $line ; done \
47+
# \n export LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so \
48+
# \n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0' \
49+
# > /etc/services.d/rstudio/run
50+
#

ubuntu/10.0/install_R.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo "deb https://cloud.r-project.org/bin/linux/ubuntu ${UBUNTU_VERSION}-cran35/" >> /etc/apt/sources.list && \
5+
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
6+
gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - && \
7+
apt-get update && \
8+
apt-get -y install --no-install-recommends \
9+
ca-certificates \
10+
less \
11+
littler \
12+
libopenblas-base \
13+
locales \
14+
r-base-dev \
15+
vim-tiny \
16+
wget && \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
20+
locale-gen en_US.utf8 && \
21+
/usr/sbin/update-locale LANG=${LANG}
22+
23+
Rscript -e "install.packages(c('littler', 'docopt'))"
24+
ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
25+
&& ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
26+
&& ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
27+
&& ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r
28+
29+

ubuntu/10.0/install_nvtop.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
apt-get update && apt-get -y install cmake libncurses5-dev libncursesw5-dev git
5+
git clone https://github.com/Syllo/nvtop.git
6+
mkdir -p nvtop/build && cd nvtop/build
7+
cmake .. -DNVML_RETRIEVE_HEADER_ONLINE=True
8+
make
9+
make install
10+

ubuntu/10.0/install_python.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#/bin/sh
2+
set -e
3+
4+
apt-get update && apt-get install -y --no-install-recommends \
5+
libpython3-dev \
6+
python3-pip \
7+
python3-venv && \
8+
rm -rf /var/lib/apt/lists/*
9+
python3 -m venv ${PYTHON_VENV_PATH}
10+
pip3 install --no-cache-dir virtualenv
11+
12+
## Ensure RStudio inherits this env var
13+
echo "\nRETICULATE_PYTHON_ENV=${RETICULATE_PYTHON_ENV}" >> ${R_HOME}/etc/Renviron
14+
15+
## symlink these because reticulate hardwires these PATHs...
16+
ln -s ${PYTHON_VENV_PATH}/bin/pip /usr/local/bin/pip
17+
ln -s ${PYTHON_VENV_PATH}/bin/virtualenv /usr/local/bin/virtualenv
18+
19+
chown :staff ${PYTHON_VENV_PATH}
20+

ubuntu/10.0/install_rstudio.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/sh
2+
3+
S6_VERSION=${S6_VERSION:-v1.21.7.0}
4+
S6_BEHAVIOUR_IF_STAGE2_FAILS=2
5+
export PATH=/usr/lib/rstudio-server/bin:$PATH
6+
PANDOC_TEMPLATES_VERSION=${PANDOC_TEMPLATES_VERSION:-2.6}
7+
8+
## Download and install RStudio server & dependencies
9+
## Attempts to get detect latest version, otherwise falls back to version given in $VER
10+
## Symlink pandoc, pandoc-citeproc so they are available system-wide
11+
apt-get update \
12+
&& apt-get install -y --no-install-recommends \
13+
file \
14+
git \
15+
libapparmor1 \
16+
libcurl4-openssl-dev \
17+
libedit2 \
18+
libssl-dev \
19+
lsb-release \
20+
psmisc \
21+
procps \
22+
python-setuptools \
23+
sudo \
24+
wget \
25+
libclang-dev \
26+
libobjc-6-dev \
27+
libobjc4 \
28+
libgc1c2 \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
32+
if [ -z "$RSTUDIO_VERSION" ];
33+
then RSTUDIO_URL="https://www.rstudio.org/download/latest/stable/server/${UBUNTU_VERSION}/rstudio-server-latest-amd64.deb";
34+
else RSTUDIO_URL="http://download2.rstudio.org/server/${UBUNTU_VERSION}/amd64/rstudio-server-${RSTUDIO_VERSION}-amd64.deb";
35+
fi
36+
wget -q $RSTUDIO_URL \
37+
&& dpkg -i rstudio-server-*-amd64.deb \
38+
&& rm rstudio-server-*-amd64.deb
39+
40+
## Symlink pandoc & standard pandoc templates for use system-wide
41+
ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin \
42+
&& ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin \
43+
&& git clone --recursive --branch ${PANDOC_TEMPLATES_VERSION} https://github.com/jgm/pandoc-templates \
44+
&& mkdir -p /opt/pandoc/templates \
45+
&& cp -r pandoc-templates*/* /opt/pandoc/templates && rm -rf pandoc-templates* \
46+
&& mkdir /root/.pandoc && ln -s /opt/pandoc/templates /root/.pandoc/templates
47+
48+
49+
## RStudio wants an /etc/R, will populate from $R_HOME/etc
50+
mkdir -p /etc/R \
51+
&& echo "\n\
52+
\n# Configure httr to perform out-of-band authentication if HTTR_LOCALHOST \
53+
\n# is not set since a redirect to localhost may not work depending upon \
54+
\n# where this Docker container is running. \
55+
\nif(is.na(Sys.getenv('HTTR_LOCALHOST', unset=NA))) { \
56+
\n options(httr_oob_default = TRUE) \
57+
\n}" >> ${R_HOME}/etc/Rprofile.site \
58+
&& echo "PATH=${PATH}" >> ${R_HOME}/etc/Renviron
59+
60+
61+
## Need to configure non-root user for RStudio
62+
useradd rstudio \
63+
&& echo "rstudio:rstudio" | chpasswd \
64+
&& mkdir /home/rstudio \
65+
&& chown rstudio:rstudio /home/rstudio \
66+
&& addgroup rstudio staff
67+
## Prevent rstudio from deciding to use /usr/bin/R if a user apt-get installs a package
68+
69+
R_BIN=`which R`
70+
echo "rsession-which-r=${R_BIN}" >> /etc/rstudio/rserver.conf
71+
## use more robust file locking to avoid errors when using shared volumes:
72+
echo "lock-type=advisory" >> /etc/rstudio/file-locks
73+
74+
## Optional configuration file to disable authentication
75+
cp /etc/rstudio/rserver.conf /etc/rstudio/disable_auth_rserver.conf
76+
echo "auth-none=1" >> /etc/rstudio/disable_auth_rserver.conf
77+
78+
## configure git not to request password each time
79+
git config --system credential.helper 'cache --timeout=3600' \
80+
&& git config --system push.default simple
81+
82+
## Set up S6 init system
83+
wget -P /tmp/ https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
84+
&& tar xzf /tmp/s6-overlay-amd64.tar.gz -C / \
85+
&& mkdir -p /etc/services.d/rstudio \
86+
&& echo "#!/usr/bin/with-contenv bash \
87+
\n## load /etc/environment vars first: \
88+
\n for line in $( cat /etc/environment ) ; do export $line > /dev/null; done \
89+
\n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0" \
90+
> /etc/services.d/rstudio/run \
91+
&& echo "#!/bin/bash \
92+
\n rstudio-server stop" \
93+
> /etc/services.d/rstudio/finish \
94+
&& mkdir -p /home/rstudio/.rstudio/monitored/user-settings \
95+
&& echo "alwaysSaveHistory='0' \
96+
\nloadRData='0' \
97+
\nsaveAction='0'" \
98+
> /home/rstudio/.rstudio/monitored/user-settings/user-settings \
99+
&& chown -R rstudio:rstudio /home/rstudio/.rstudio
100+
101+
102+
#COPY userconf.sh /etc/cont-init.d/userconf
103+
# EXPOSE 8787
104+
# CMD ["/init"]

ubuntu/10.0/install_tensorflow-gpu.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
set -e
3+
4+
apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential \
6+
curl \
7+
libfreetype6-dev \
8+
libhdf5-serial-dev \
9+
libzmq3-dev \
10+
pkg-config \
11+
software-properties-common \
12+
unzip
13+
14+
## FIXME set versions Consider renv
15+
#R -e "renv::restore()"
16+
pip3 install --no-cache-dir tensorflow-gpu tensorflow-probability keras h5py pyyaml requests Pillow
17+
chown -R rstudio:rstudio ${PYTHON_VENV_PATH}
18+
19+
R -e "install.packages('keras')"
20+
R -e "install.packages('remotes'); remotes::install_github('greta-dev/greta')"
21+

ubuntu/10.0/install_tidyverse.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
apt-get update -qq && apt-get -y --no-install-recommends install \
5+
libxml2-dev \
6+
libcairo2-dev \
7+
libsqlite3-dev \
8+
libmariadbd-dev \
9+
libmariadb-client-lgpl-dev \
10+
libpq-dev \
11+
libssh2-1-dev \
12+
unixodbc-dev \
13+
libsasl2-dev && \
14+
rm -rf /var/lib/apt/lists/*
15+
16+
install2.r --error \
17+
--deps TRUE \
18+
tidyverse \
19+
dplyr \
20+
devtools \
21+
formatR \
22+
remotes \
23+
selectr \
24+
caTools \
25+
BiocManager
26+

ubuntu/10.0/install_verse.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
export PATH=$PATH:/opt/TinyTeX/bin/x86_64-linux/
6+
7+
## Add LaTeX, rticles and bookdown support
8+
wget "https://travis-bin.yihui.name/texlive-local.deb" \
9+
&& dpkg -i texlive-local.deb \
10+
&& rm texlive-local.deb \
11+
&& apt-get update \
12+
&& apt-get install -y --no-install-recommends \
13+
cmake \
14+
default-jdk \
15+
fonts-roboto \
16+
ghostscript \
17+
libbz2-dev \
18+
libicu-dev \
19+
liblzma-dev \
20+
libhunspell-dev \
21+
libmagick++-dev \
22+
librdf0-dev \
23+
libv8-dev \
24+
qpdf \
25+
texinfo \
26+
ssh \
27+
less \
28+
vim \
29+
libzmq3-dev \
30+
libopenmpi-dev \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
install2.r --error tinytex
34+
35+
## Admin-based install of TinyTeX:
36+
wget -qO- \
37+
"https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
38+
sh -s - --admin --no-path \
39+
&& mv ~/.TinyTeX /opt/TinyTeX \
40+
&& /opt/TinyTeX/bin/*/tlmgr path add \
41+
&& tlmgr install metafont mfware inconsolata tex ae parskip listings \
42+
&& tlmgr path add \
43+
&& Rscript -e "tinytex::r_texmf()" \
44+
&& chown -R root:staff /opt/TinyTeX \
45+
&& chown -R root:staff ${R_HOME}/site-library \
46+
&& chmod -R g+w /opt/TinyTeX \
47+
&& chmod -R g+wx /opt/TinyTeX/bin \
48+
&& echo "PATH=${PATH}" >> ${R_HOME}/etc/Renviron
49+
50+
51+
install2.r --error --deps TRUE \
52+
bookdown rticles rmdshower rJava
53+
54+

0 commit comments

Comments
 (0)