From 87726cf095181d1340736f7e19ec8e8617132bdf Mon Sep 17 00:00:00 2001 From: Carl Boettiger Date: Tue, 12 Mar 2019 11:30:23 -0700 Subject: [PATCH] don't set LD_PRELOAD globally, and can't set it Renviron --- cuda/base/Dockerfile | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cuda/base/Dockerfile b/cuda/base/Dockerfile index 781ca2c..0cabcef 100644 --- a/cuda/base/Dockerfile +++ b/cuda/base/Dockerfile @@ -73,8 +73,7 @@ RUN echo "rsession-ld-library-path=$LD_LIBRARY_PATH" | \ echo "\n\ \nCUDA_HOME=$CUDA_HOME \ \nCUDA_PATH=$CUDA_PATH \ - \nPATH=$PATH \ - \nLD_PRELOAD=/usr/local/cuda/lib64/libnvblas.so.$CUDA_VERSION" \ + \nPATH=$PATH" \ >> /usr/local/lib/R/etc/Renviron ## Allow R to use CUDA for BLAS, with fallback on openblas @@ -84,4 +83,25 @@ RUN echo "NVBLAS_LOGFILE nvblas.log \ ENV NVBLAS_CONFIG_FILE=/etc/nvblas.conf +## We don't want to set LD_PRELOAD globally +ENV CUDA_BLAS=/usr/local/cuda/lib64/libnvblas.so.$CUDA_VERSION + +RUN mv /usr/local/bin/R /usr/local/bin/R_ && \ + mv /usr/local/bin/Rscript /usr/local/bin/Rscript_ && \ + echo "#!/bin/sh + \nLD_PRELOAD=$CUDA_BLAS /usr/local/bin/R_ \"\$@\"" \ + > /usr/local/bin/R && \ + chmod +x /usr/local/bin/R && \ + echo "#!/bin/sh + \nLD_PRELOAD=$CUDA_BLAS /usr/local/bin/Rscript_ \"\$@\"" \ + > /usr/local/bin/Rscript && \ + chmod +x /usr/local/bin/Rscript + +RUN 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=$CUDA_BLAS \ + \n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0" \ + > /etc/services.d/rstudio/run +