Created
January 8, 2018 21:28
-
-
Save icaoberg/22728731a186a0ab22b0777017d7aab0 to your computer and use it in GitHub Desktop.
Example - Using TensorFlow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "Setting up environment" | |
if [ -d tensorflow ]; then | |
rm -rfv tensorflow | |
fi | |
if [ ! -d tensorflow ]; then | |
mkdir tensorflow | |
fi | |
echo "Clone a repository with TensorFlow examples" | |
git clone https://github.com/aymericdamien/TensorFlow-Examples.git && mv -v TensorFlow-Examples tensorflow | |
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 | |
pip install -U numpy | |
pip install tensorflow | |
cd TensorFlow-Examples/examples/3_NeuralNetworks/ | |
python neural_network.py | |
deactivate | |
EOF | |
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