highspeed-decoding-cluster.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/bash
  2. # ==============================================================================
  3. # SCRIPT INFORMATION:
  4. # ==============================================================================
  5. # SCRIPT: PARALELLIZE THE DECODING SCRIPT ON THE MPIB CLUSTER (TARDIS)
  6. # PROJECT: HIGHSPEED
  7. # WRITTEN BY LENNART WITTKUHN, 2018 - 2020
  8. # CONTACT: WITTKUHN AT MPIB HYPHEN BERLIN DOT MPG DOT DE
  9. # MAX PLANCK RESEARCH GROUP NEUROCODE
  10. # MAX PLANCK INSTITUTE FOR HUMAN DEVELOPMENT (MPIB)
  11. # MAX PLANCK UCL CENTRE FOR COMPUTATIONAL PSYCHIATRY AND AGEING RESEARCH
  12. # LENTZEALLEE 94, 14195 BERLIN, GERMANY
  13. # ==============================================================================
  14. # DEFINE ALL PATHS:
  15. # ==============================================================================
  16. # define the name of the current task:
  17. TASK_NAME="highspeed-decoding"
  18. # define the name of the project:
  19. PROJECT_NAME="highspeed"
  20. # path to the home directory:
  21. PATH_HOME=/home/mpib/wittkuhn
  22. # path to the current code folder:
  23. PATH_CODE=${PATH_HOME}/${PROJECT_NAME}/${TASK_NAME}/code/decoding
  24. # cd into the directory of the current script:
  25. cd ${PATH_CODE}
  26. # path to the current script:
  27. PATH_SCRIPT=${PATH_CODE}/highspeed_decoding.py
  28. # path to the output directory:
  29. PATH_OUT=${PATH_HOME}/${PROJECT_NAME}/${TASK_NAME}/decoding
  30. # path to the working directory:
  31. PATH_WORK=${PATH_HOME}/${PROJECT_NAME}/${TASK_NAME}/work
  32. # path to the log directory:
  33. PATH_LOG=${PATH_HOME}/${PROJECT_NAME}/${TASK_NAME}/logs/$(date '+%Y%m%d_%H%M%S')
  34. # ==============================================================================
  35. # CREATE RELEVANT DIRECTORIES:
  36. # ==============================================================================
  37. # create output directory:
  38. if [ ! -d ${PATH_OUT} ]; then
  39. mkdir -p ${PATH_OUT}
  40. fi
  41. # create working directory:
  42. if [ ! -d ${PATH_WORK} ]; then
  43. mkdir -p ${PATH_WORK}
  44. fi
  45. # create directory for log files:
  46. if [ ! -d ${PATH_LOG} ]; then
  47. mkdir -p ${PATH_LOG}
  48. fi
  49. # ==============================================================================
  50. # DEFINE PARAMETERS:
  51. # ==============================================================================
  52. # maximum number of cpus per process:
  53. N_CPUS=1
  54. # memory demand in *GB*
  55. MEM=20GB
  56. # user-defined subject list
  57. PARTICIPANTS=$1
  58. # ==============================================================================
  59. # RUN THE DECODING:
  60. # ==============================================================================
  61. # initialize a counter for the subjects:
  62. SUB_COUNT=0
  63. for i in {1..40}; do
  64. # turn the subject id into a zero-padded number:
  65. SUB=$(printf "%02d\n" ${i})
  66. # start slurm job file:
  67. echo "#!/bin/bash" > job
  68. # name of the job
  69. echo "#SBATCH --job-name highspeed-decoding-sub-${SUB}" >> job
  70. # set the expected maximum running time for the job:
  71. echo "#SBATCH --time 12:00:00" >> job
  72. # determine how much RAM your operation needs:
  73. echo "#SBATCH --mem ${MEM}" >> job
  74. # request multiple cpus:
  75. echo "#SBATCH --cpus-per-task ${N_CPUS}" >> job
  76. # write (output) log to log folder:
  77. echo "#SBATCH --output ${PATH_LOG}/highspeed-decoding-sub-${SUB}-%j.out" >> job
  78. # email notification on abort/end, use 'n' for no notification:
  79. echo "#SBATCH --mail-type NONE" >> job
  80. # start in the current directory:
  81. echo "#SBATCH --workdir ." >> job
  82. # activate virtual environment on cluster:
  83. echo "source /etc/bash_completion.d/virtualenvwrapper" >> job
  84. echo "workon highspeed-decoding" >> job
  85. # define the main command:
  86. echo "python3 ${PATH_SCRIPT} ${SUB}" >> job
  87. # submit job to cluster queue and remove it to avoid confusion:
  88. sbatch job
  89. rm -f job
  90. done