gridengine/examples/jobs/show_available_cuda_devices.sh
Kasper D. Fischer fd6c9867f2 add example scripts
This scripts are for testing and to show how to write your own gridengine scripts
2021-05-27 12:27:03 +02:00

45 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#############################################################
# use tensorflow to show availabel GPU devices #
# optional argument is the conda environment to use #
# default is tf-gpu #
#############################################################
TF_ENV=${1:-tf-gpu}
if [ ${TF_ENV} = "-h" ] ; then
echo "Usage: $(basename $0) [tensor_flow_env]"
exit 0
fi
#############################################################
# set qsub options #
#############################################################
#$ -cwd
#$ -N CUDAtest
#$ -l memory=64G,h_vmem=64G
#############################################################
# initialize conda #
#############################################################
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
#############################################################
# activate conda env ent call python commands #
#############################################################
conda activate ${TF_ENV}
export TF_CPP_MIN_LOG_LEVEL=3
export TF_FORCE_GPU_ALLOW_GROWTH=true
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-''}."
python3 -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
conda deactivate