Skip to content

Instantly share code, notes, and snippets.

@skaae
Created June 17, 2014 07:46
Show Gist options
  • Save skaae/a175b09655777d6b96a3 to your computer and use it in GitHub Desktop.
Save skaae/a175b09655777d6b96a3 to your computer and use it in GitHub Desktop.
Launch script for matlab with GPU
#!/bin/sh
#
# stdout/stderr redirection
#PBS -N NAME_OF_JOB1
#PBS -o $PBS_JOBNAME.$PBS_JOBID.out
#PBS -e $PBS_JOBNAME.$PBS_JOBID.err
#PBS -l nodes=1:gpus=1
# Execute the job from the current working directory
cd $PBS_O_WORKDIR
ML_GPUDEVICE=`sed 's/^.*gpu//' $PBS_GPUFILE`
export ML_GPUDEVICE
echo -n gpu${ML_GPUDEVICE}@
/bin/hostname
matlab -nodisplay -logfile test.out -r "gpuDevice(str2num(getenv('ML_GPUDEVICE')) + 1); myscript"
@skaae
Copy link
Author

skaae commented Jun 17, 2014

You need to run the script through the dtu server system

For debugging GPU code you can run matlab in desktop mode by:

  1. From the terminal request a GPU
  gpush -l nodes=1:gpus=1 -v DISPLAY -q hpc
  1. Run the following shell script
#!/bin/sh
#
ML_GPUDEVICE=`sed 's/^.*gpu//' $PBS_GPUFILE`
export ML_GPUDEVICE
echo -n gpu${ML_GPUDEVICE}@/bin/hostname
matlab -r "gpuDevice(str2num(getenv('ML_GPUDEVICE')) + 1); desktop"
  1. In matlab test that you have a GPU
a = gpuArray.zeros(10,10);
gpuDevice()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment