no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | en:services:application_services:high_performance_computing:software:tensorflow [2021/04/22 15:35] (current) – created mboden | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== TensorFlow ====== | ||
+ | [[https:// | ||
+ | ==== Installing TensorFlow ==== | ||
+ | It is recommended to use Anaconda to create a virtual python environment and install the desired version of tensorflow within that environment. | ||
+ | <code bash> | ||
+ | module load anaconda3 | ||
+ | source $ANACONDA3_ROOT/ | ||
+ | conda create -n myenv python=3.8.8 | ||
+ | conda activate myenv | ||
+ | conda install tensorflow-gpu==2.2.0 | ||
+ | </ | ||
+ | If you do not want to use GPUs simply replace the last line with <code bash> | ||
+ | |||
+ | ==== Testing the installation ==== | ||
+ | To run TensorFlow on GPUs, load the correct modules and submit a job to the gpu partition. | ||
+ | <file bash jobscript.sh> | ||
+ | #!/bin/bash | ||
+ | #SBATCH -p gpu | ||
+ | #SBATCH -t 1 | ||
+ | #SBATCH --gpus-per-node 1 | ||
+ | |||
+ | module load anaconda3 | ||
+ | |||
+ | source $ANACONDA3_ROOT/ | ||
+ | conda activate myenv | ||
+ | |||
+ | python tftest.py | ||
+ | </ | ||
+ | |||
+ | <file python tftest.py> | ||
+ | import tensorflow as tf | ||
+ | tf.compat.v1.disable_eager_execution() | ||
+ | hello = tf.constant(' | ||
+ | sess = tf.compat.v1.Session() | ||
+ | print(sess.run(hello)) | ||
+ | </ | ||
+ | And then submit the job using Slurm: <code bash> | ||
+ | sbatch jobscript.sh</ | ||
+ | |||
+ | The output file should contain | ||
+ | < | ||
+ | The output (if any) follows: | ||
+ | |||
+ | b' | ||
+ | and also information about the GPUs selected. | ||
+ | |||
+ | === Testing CPU only installation === | ||
+ | If you want to test a CPU only installation, | ||
+ | |||
+ | ==== Using TensorFlow ==== | ||
+ | You can now use TensorFlow in your python scripts. Please read [[en: |