Skip to content

Commit

Permalink
Merge pull request #26 from rocker-org/ubuntu
Browse files Browse the repository at this point in the history
Ubuntu-based image
  • Loading branch information
cboettig authored Oct 9, 2019
2 parents e2f7433 + a08d32d commit 71c4f2f
Show file tree
Hide file tree
Showing 19 changed files with 959 additions and 0 deletions.
61 changes: 61 additions & 0 deletions ubuntu/10.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM nvidia/cuda:10.0-cudnn7-devel

LABEL org.label-schema.license="GPL-2.0" \
org.label-schema.vcs-url="https://github.com/rocker-org/rocker-versioned" \
org.label-schema.vendor="Rocker Project" \
maintainer="Carl Boettiger <[email protected]>"

ENV TERM=xterm

## cuda:9.0 is xenial, cuda:10.0 is bionic
ARG UBUNTU_VERSION=bionic
ARG R_HOME=/usr/lib/R
ARG DEBIAN_FRONTEND=noninteractive


#ENV R_VERSION=${R_VERSION:-3.6.0}
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
COPY install_R.sh /tmp/install_R.sh
RUN . /tmp/install_R.sh



COPY install_rstudio.sh /tmp/install_rstudio.sh
#RUN . /tmp/install_rstudio.sh
COPY userconf.sh /etc/cont-init.d/userconf
EXPOSE 8787
#CMD ["/init"]



COPY install_tidyverse.sh /tmp/install_tidyverse.sh
#RUN . /tmp/install_tidyverse.sh



COPY install_verse.sh /tmp/install_verse.sh
#RUN . /tmp/install_verse.sh



## Use Configure CUDA for R, use NVidia libs for BLAS
ENV CUDA_HOME=/usr/local/cuda
ENV PATH=$PATH:$CUDA_HOME/bin
ENV LD_LIBRARY_PATH=$CUDA_HOME/lib64/libnvblas.so:$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64
ENV NVBLAS_CONFIG_FILE=/etc/nvblas.conf
COPY config_R_cuda.sh /tmp/config_R_cuda.sh
RUN . /tmp/config_R_cuda.sh


ENV PYTHON_VENV_PATH=/opt/venv
ENV RETICULATE_PYTHON_ENV=$PYTHON_VENV_PATH
ENV PATH=${PYTHON_VENV_PATH}/bin:${PATH}
COPY install_python.sh /tmp/install_python.sh
RUN . /tmp/install_python.sh



COPY install_tensorflow-gpu.sh /tmp/install_tensorflow-gpu.sh
#RUN . /tmp/install_tensorflow-gpu.sh

50 changes: 50 additions & 0 deletions ubuntu/10.0/config_R_cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

set -e

## CUDA environmental variables configuration for RStudio

## cli R inherits these, but RStudio needs to have these set in as follows:
## (From https://tensorflow.rstudio.com/tools/local_gpu.html#environment-variables)
echo "\n\
\nCUDA_HOME=$CUDA_HOME\
\nPATH=$PATH" >> ${R_HOME}/etc/Renviron

if test -f /etc/rstudio/rserver.conf; then
echo "rsession-ld-library-path=$LD_LIBRARY_PATH" >> /etc/rstudio/rserver.conf
fi

touch /var/log/nvblas.log && chown :staff /var/log/nvblas.log

## Configure R & RStudio to use drop-in CUDA blas
## Allow R to use CUDA for BLAS, with fallback on openblas
echo "\nNVBLAS_LOGFILE /var/log/nvblas.log \
\nNVBLAS_CPU_BLAS_LIB /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 \
\nNVBLAS_GPU_LIST ALL" > /etc/nvblas.conf

echo "NVBLAS_CONFIG_FILE=$NVBLAS_CONFIG_FILE" >> ${R_HOME}/etc/Renviron


## We don't want to set LD_PRELOAD globally
##ENV LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so
#
### Instead, we will set it before calling R, Rscript, or RStudio:
#mv /usr/bin/R /usr/bin/R_
#mv /usr/bin/Rscript /usr/bin/Rscript_
#
#echo '\#!/bin/sh \
# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/R_ "$@"' \
# > /usr/bin/R && \
# chmod +x /usr/bin/R && \
# echo '#!/bin/sh \
# \n LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so /usr/bin/Rscript_ "$@"' \
# > /usr/bin/Rscript && \
# chmod +x /usr/bin/Rscript
#
#echo '#!/usr/bin/with-contenv bash \
# \n## load /etc/environment vars first: \
# \n for line in \$( cat /etc/environment ) ; do export $line ; done \
# \n export LD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so \
# \n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0' \
# > /etc/services.d/rstudio/run
#
29 changes: 29 additions & 0 deletions ubuntu/10.0/install_R.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
set -e

echo "deb https://cloud.r-project.org/bin/linux/ubuntu ${UBUNTU_VERSION}-cran35/" >> /etc/apt/sources.list && \
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | apt-key add - && \
apt-get update && \
apt-get -y install --no-install-recommends \
ca-certificates \
less \
littler \
libopenblas-base \
locales \
r-base-dev \
vim-tiny \
wget && \
rm -rf /var/lib/apt/lists/*

echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
locale-gen en_US.utf8 && \
/usr/sbin/update-locale LANG=${LANG}

Rscript -e "install.packages(c('littler', 'docopt'))"
ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
&& ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
&& ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
&& ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r


10 changes: 10 additions & 0 deletions ubuntu/10.0/install_nvtop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

apt-get update && apt-get -y install cmake libncurses5-dev libncursesw5-dev git
git clone https://github.com/Syllo/nvtop.git
mkdir -p nvtop/build && cd nvtop/build
cmake .. -DNVML_RETRIEVE_HEADER_ONLINE=True
make
make install

20 changes: 20 additions & 0 deletions ubuntu/10.0/install_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#/bin/sh
set -e

apt-get update && apt-get install -y --no-install-recommends \
libpython3-dev \
python3-pip \
python3-venv && \
rm -rf /var/lib/apt/lists/*
python3 -m venv ${PYTHON_VENV_PATH}
pip3 install --no-cache-dir virtualenv

## Ensure RStudio inherits this env var
echo "\nRETICULATE_PYTHON_ENV=${RETICULATE_PYTHON_ENV}" >> ${R_HOME}/etc/Renviron

## symlink these because reticulate hardwires these PATHs...
ln -s ${PYTHON_VENV_PATH}/bin/pip /usr/local/bin/pip
ln -s ${PYTHON_VENV_PATH}/bin/virtualenv /usr/local/bin/virtualenv

chown :staff ${PYTHON_VENV_PATH}

104 changes: 104 additions & 0 deletions ubuntu/10.0/install_rstudio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/sh

S6_VERSION=${S6_VERSION:-v1.21.7.0}
S6_BEHAVIOUR_IF_STAGE2_FAILS=2
export PATH=/usr/lib/rstudio-server/bin:$PATH
PANDOC_TEMPLATES_VERSION=${PANDOC_TEMPLATES_VERSION:-2.6}

## Download and install RStudio server & dependencies
## Attempts to get detect latest version, otherwise falls back to version given in $VER
## Symlink pandoc, pandoc-citeproc so they are available system-wide
apt-get update \
&& apt-get install -y --no-install-recommends \
file \
git \
libapparmor1 \
libcurl4-openssl-dev \
libedit2 \
libssl-dev \
lsb-release \
psmisc \
procps \
python-setuptools \
sudo \
wget \
libclang-dev \
libobjc-6-dev \
libobjc4 \
libgc1c2 \
&& rm -rf /var/lib/apt/lists/*


if [ -z "$RSTUDIO_VERSION" ];
then RSTUDIO_URL="https://www.rstudio.org/download/latest/stable/server/${UBUNTU_VERSION}/rstudio-server-latest-amd64.deb";
else RSTUDIO_URL="http://download2.rstudio.org/server/${UBUNTU_VERSION}/amd64/rstudio-server-${RSTUDIO_VERSION}-amd64.deb";
fi
wget -q $RSTUDIO_URL \
&& dpkg -i rstudio-server-*-amd64.deb \
&& rm rstudio-server-*-amd64.deb

## Symlink pandoc & standard pandoc templates for use system-wide
ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin \
&& ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin \
&& git clone --recursive --branch ${PANDOC_TEMPLATES_VERSION} https://github.com/jgm/pandoc-templates \
&& mkdir -p /opt/pandoc/templates \
&& cp -r pandoc-templates*/* /opt/pandoc/templates && rm -rf pandoc-templates* \
&& mkdir /root/.pandoc && ln -s /opt/pandoc/templates /root/.pandoc/templates


## RStudio wants an /etc/R, will populate from $R_HOME/etc
mkdir -p /etc/R \
&& echo "\n\
\n# Configure httr to perform out-of-band authentication if HTTR_LOCALHOST \
\n# is not set since a redirect to localhost may not work depending upon \
\n# where this Docker container is running. \
\nif(is.na(Sys.getenv('HTTR_LOCALHOST', unset=NA))) { \
\n options(httr_oob_default = TRUE) \
\n}" >> ${R_HOME}/etc/Rprofile.site \
&& echo "PATH=${PATH}" >> ${R_HOME}/etc/Renviron


## Need to configure non-root user for RStudio
useradd rstudio \
&& echo "rstudio:rstudio" | chpasswd \
&& mkdir /home/rstudio \
&& chown rstudio:rstudio /home/rstudio \
&& addgroup rstudio staff
## Prevent rstudio from deciding to use /usr/bin/R if a user apt-get installs a package

R_BIN=`which R`
echo "rsession-which-r=${R_BIN}" >> /etc/rstudio/rserver.conf
## use more robust file locking to avoid errors when using shared volumes:
echo "lock-type=advisory" >> /etc/rstudio/file-locks

## Optional configuration file to disable authentication
cp /etc/rstudio/rserver.conf /etc/rstudio/disable_auth_rserver.conf
echo "auth-none=1" >> /etc/rstudio/disable_auth_rserver.conf

## configure git not to request password each time
git config --system credential.helper 'cache --timeout=3600' \
&& git config --system push.default simple

## Set up S6 init system
wget -P /tmp/ https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz \
&& tar xzf /tmp/s6-overlay-amd64.tar.gz -C / \
&& mkdir -p /etc/services.d/rstudio \
&& echo "#!/usr/bin/with-contenv bash \
\n## load /etc/environment vars first: \
\n for line in $( cat /etc/environment ) ; do export $line > /dev/null; done \
\n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0" \
> /etc/services.d/rstudio/run \
&& echo "#!/bin/bash \
\n rstudio-server stop" \
> /etc/services.d/rstudio/finish \
&& mkdir -p /home/rstudio/.rstudio/monitored/user-settings \
&& echo "alwaysSaveHistory='0' \
\nloadRData='0' \
\nsaveAction='0'" \
> /home/rstudio/.rstudio/monitored/user-settings/user-settings \
&& chown -R rstudio:rstudio /home/rstudio/.rstudio


#COPY userconf.sh /etc/cont-init.d/userconf
# EXPOSE 8787
# CMD ["/init"]
21 changes: 21 additions & 0 deletions ubuntu/10.0/install_tensorflow-gpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e

apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
libfreetype6-dev \
libhdf5-serial-dev \
libzmq3-dev \
pkg-config \
software-properties-common \
unzip

## FIXME set versions Consider renv
#R -e "renv::restore()"
pip3 install --no-cache-dir tensorflow-gpu tensorflow-probability keras h5py pyyaml requests Pillow
chown -R rstudio:rstudio ${PYTHON_VENV_PATH}

R -e "install.packages('keras')"
R -e "install.packages('remotes'); remotes::install_github('greta-dev/greta')"

26 changes: 26 additions & 0 deletions ubuntu/10.0/install_tidyverse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -e

apt-get update -qq && apt-get -y --no-install-recommends install \
libxml2-dev \
libcairo2-dev \
libsqlite3-dev \
libmariadbd-dev \
libmariadb-client-lgpl-dev \
libpq-dev \
libssh2-1-dev \
unixodbc-dev \
libsasl2-dev && \
rm -rf /var/lib/apt/lists/*

install2.r --error \
--deps TRUE \
tidyverse \
dplyr \
devtools \
formatR \
remotes \
selectr \
caTools \
BiocManager

54 changes: 54 additions & 0 deletions ubuntu/10.0/install_verse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -e

export PATH=$PATH:/opt/TinyTeX/bin/x86_64-linux/

## Add LaTeX, rticles and bookdown support
wget "https://travis-bin.yihui.name/texlive-local.deb" \
&& dpkg -i texlive-local.deb \
&& rm texlive-local.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
cmake \
default-jdk \
fonts-roboto \
ghostscript \
libbz2-dev \
libicu-dev \
liblzma-dev \
libhunspell-dev \
libmagick++-dev \
librdf0-dev \
libv8-dev \
qpdf \
texinfo \
ssh \
less \
vim \
libzmq3-dev \
libopenmpi-dev \
&& rm -rf /var/lib/apt/lists/*

install2.r --error tinytex

## Admin-based install of TinyTeX:
wget -qO- \
"https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
sh -s - --admin --no-path \
&& mv ~/.TinyTeX /opt/TinyTeX \
&& /opt/TinyTeX/bin/*/tlmgr path add \
&& tlmgr install metafont mfware inconsolata tex ae parskip listings \
&& tlmgr path add \
&& Rscript -e "tinytex::r_texmf()" \
&& chown -R root:staff /opt/TinyTeX \
&& chown -R root:staff ${R_HOME}/site-library \
&& chmod -R g+w /opt/TinyTeX \
&& chmod -R g+wx /opt/TinyTeX/bin \
&& echo "PATH=${PATH}" >> ${R_HOME}/etc/Renviron


install2.r --error --deps TRUE \
bookdown rticles rmdshower rJava


Loading

0 comments on commit 71c4f2f

Please sign in to comment.