Bootstrap: docker
From: nvidia/cuda:10.1-cudnn7-devel-centos7

%setup
  #Runs on host. The path to the image is $SINGULARITY_ROOTFS

%post
  #Post setup, runs inside the image

  #Default mount point used in Shef Unis ShARC cluster
  mkdir /scratch /data /shared 

  #Nvidia driver file mount paths
  mkdir /nvlib /nvbin

  #Add nvidia driver paths to the environment variables
  echo "\n #Nvidia driver paths \n" >> /environment
  echo 'export PATH="/nvbin:$PATH"' >> /environment
  echo 'export LD_LIBRARY_PATH="/nvlib:$LD_LIBRARY_PATH"' >> /environment

  #Add CUDA paths
  echo "\n #Cuda paths \n" >> /environment
  echo 'export CPATH="/usr/local/cuda/include:$CPATH"' >> /environment
  echo 'export PATH="/usr/local/cuda/bin:$PATH"' >> /environment
  echo 'export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"' >> /environment
  echo 'export CUDA_HOME="/usr/local/cuda"' >> /environment
  yum -y update
  yum -y install yum-utils
  yum -y groupinstall development
  yum -y install https://centos7.iuscommunity.org/ius-release.rpm
  yum -y install python36u
  yum -y install python36u-devel
  yum -y install python36u-pip	
  echo "Installed system dependencies"
  pip3.6 install --upgrade pip	
  pip3.6 install --no-cache-dir numpy tensorflow-gpu

  
%runscript
  #Executes when the "singularity run" command is used
  #Useful when you want the container to run as an executable


%test
  #Test script to verify that the image is built and running correctly