Because tf.config.set_soft_device_placement is turned on, even if this code is assigned a CPU-only node, it will still run. The multiplication step will be carried out using the CPU.
Now, let's write our SLURM job script, testTF.sbatch, which contains the following:
#!/bin/bash# Job name:#SBATCH --job-name=test_matmul## Request GPU:#SBATCH --gpus=v100:1## Memory:#SBATCH --mem-per-cpu=20G## Wall clock limit (minutes or hours:minutes or days-hours):#SBATCH --time=20## Standard out and error:#SBATCH --output=%x-%j.SLURMoutecho"This script comes from ICER's TensorFlow example"# [Insert command to load your Conda] -- see https://docs.icer.msu.edu/Using_conda/
condaactivatetf_Jul2024
exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib:/mnt/home/user123/miniforge3/envs/tf_Jul2024/lib/python3.10/site-packages/tensorrt
pythonmatmul.tf2.py
condadeactivate
To submit it, run sbatch testTF.sbatch from the command line. The final result will be written to the file test_matmul-<jobid>.SLURMout.