简体   繁体   中英

How do I enable python submission scripts on my slurm cluster?

I have access to a cluster using slurm and want to extend it to use python for sbatch submission scripts. How do I do that?

I tried giving my submission script different paths to the interpreter:

#!/bin/python
#!/usr/bin/python
#!/usr/bin/env python

with no success in any of them. How do I activate this feature in my cluster?


For completion here is my test submission script:

#!/usr/bin/env python
#SBATCH --mail-type=ALL
#SBATCH --mail-user=rene_sax14@yahoo.com
#SBATCH --array=1-1
#SBATCH --partition=gpux1

import sys

print(sys.version)
print(sys.path)

def helloworld():
    print('Hello World')

if __name__ == '__main__':
    print('---> DONE')

Error message:

cat slurm-968_1.out 
import: unable to open X server `' @ error/import.c/ImportImageCommand/369.
/var/spool/slurm/d/job00968/slurm_script: line 19: syntax error near unexpected token `sys.version'
/var/spool/slurm/d/job00968/slurm_script: line 19: `print(sys.version)'
$ cat python_sub_script.py 
#!/bin/python3.6
#SBATCH --mail-type=ALL
#SBATCH --mail-user=rene_sax14@yahoo.com
#SBATCH --array=1-1
#SBATCH --partition=gpux1

import sys

print(sys.version)
print(sys.path)

def helloworld():
    print('Hello World')

if __name__ == '__main__':
    print('---> DONE')

I did check this time if there was a python3.6 at bin so that is not the issue check it out:

$ ls -lah /bin/python3.6
-rwxr-xr-x 2 root root 67K Aug  7  2019 /bin/python3.6

related/crossposted:

For me it seems it wasn't working because the submission command I was using wasn't the standard sbatch and it overwrote my flags.

It seems if you make sure you do have a valid path to a interpreter (to check that do ls path/to/interperter and that should be enough. eg

#!/bin/python3.6
#SBATCH --mail-type=ALL
#SBATCH --mail-user=rene_sax14@yahoo.com
#SBATCH --array=1-1
#SBATCH --partition=debug
#SBATCH --time=4:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=16
#SBATCH --sockets-per-node=1
#SBATCH --cores-per-socket=4
#SBATCH --threads-per-core=4
#SBATCH --mem-per-cpu=1200
#SBATCH --export=ALL
#SBATCH --gres=gpu:v100:1

import sys

print(sys.version)
print(sys.path)

def helloworld():
    print('Hello World')

if __name__ == '__main__':
    helloworld()
    print('---> DONE')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM