Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Created January 8, 2018 21:38
Show Gist options
  • Save icaoberg/bb6ca6ec272030bcd526e52c10ee8405 to your computer and use it in GitHub Desktop.
Save icaoberg/bb6ca6ec272030bcd526e52c10ee8405 to your computer and use it in GitHub Desktop.
My personal Tensorflow template
#!/bin/bash
#SBATCH -p gpu
#SBATCH -e tensorflow.%j.err
#SBATCH -o tensorflow.%j.out
#SBATCH -t 48:00:00
#SBATCH -n 1
#SBATCH --mem=32G
#SBATCH --gres=gpu:1
#so we can use modules
source /etc/profile.d/modules.sh
module load singularity
export LC_ALL=C
echo "Write helper script with commands to run inside the container"
cat << EOF > script.sh
#!/bin/bash
cd tensorflow
virtualenv --system-site-packages .
source ./bin/activate
#Remember to install all packages
pip install -U numpy
pip install tensorflow
#The file this_is_your_script.py is your Python script
python this_is_your_script.py
deactivate
EOF
#the latest container to use TensorFlow with
echo "Run script inside singularity container"
singularity exec /containers/images/ubuntu-16.04-lts-tensorflow-1.3.0_cudnn-8.0-v6.img /bin/bash ./script.sh
echo "Remove helper script from disk"
if [ -f ./script.sh ]; then
rm -fv ./script.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment