how to create two namd jobs in a single script with 2 x dual cuda gpus?

From: nam kim (namkkim_at_gmail.com)
Date: Sat Aug 01 2015 - 16:36:15 CDT

computing node has 32 cores with 4 GTX 980 gpus.
with CUDA_VISIBLE_DEVICES, I'd like to run two namd jobs with a pair of
gpus. script below I wrote failed. Could you help me to find errors?
--------------------------------------------------

#!/bin/bash
#SBATCH -D /home/rhye
#SBATCH -J grk4-R65L
#SBATCH --partition=gpus
#SBATCH --get-user-env
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=2
#SBATCH --gres=gpu:2
#SBATCH --time=00:30:00

source /etc/profile.d/modules.sh
srun hostname -s | sort -u >slurm.hosts

CUDA_HOME=/cm/shared/apps/cuda70/toolkit/current
export NAMD_HOME=/home/namkim/NAMD-GPU/bin
export PATH=$CUDA_HOME/bin:$NAMD_HOME:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$NAMD_HOME:$LD_LIBRARY_PATH
export CUDA_VISIBLE_DEVICES=0,1

cd /home/rhye/R65L-SIMULATION
export NAMD_JOBNAME=/home/rhye/R65L-SIMULATION

srun $NAMD_HOME/charmrun ++local +p16 $NAMD_HOME/namd2 +idlepoll +devices
$CUDA_VISIBLE_DEVICES newer-sample5.conf >& speed-testx1.log &

export CUDA_VISIBLE_DEVICES=2,3

srun $NAMD_HOME/charmrun ++local +p16 $NAMD_HOME/namd2 +idlepoll +devices
$CUDA_VISIBLE_DEVICES newer-sample5.conf >& speed-testx2.log &

wait

rm -f slurm.hosts

This archive was generated by hypermail 2.1.6 : Thu Dec 31 2015 - 23:22:00 CST