7

I've written a python script that requires two arguments and works just fine when I run it on the command line with:

pythonscript.py arg1 arg2

I need to run this in a SLURM batch script, but whenever I do I get an "illegal instruction" error and a core dump. This is an example of the script I'm using:

#!/bin/bash
# Set your minimum acceptable walltime, format: day-hours:minutes:seconds
#SBATCH --time=0-00:30:00

# Set name of job shown in squeue
#SBATCH --job-name pythonscript

# Request CPU resources
#SBATCH --ntasks=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1

# Memory usage (MB)
#SBATCH --mem-per-cpu=3000

# Use modules to set the software environment
module purge
module load python/2.7.8-gcc

pythonscript.py arg1 arg2

I've spent a lot of time trying to figure out exactly what is causing the core dumps, and this is what I've narrowed it down to. It only crashes when run from the batch script and only when I'm trying to run the script with arguments. When I modify it to run without arguments, it runs properly. Can anyone tell me how to pass these arguments to my python script within a SLURM script?

jeb
  • 78,592
  • 17
  • 171
  • 225
Jiffy
  • 73
  • 1
  • 2
  • 4
  • Could you run `gdb `, and add the backtrace to your post? Also does pythonscript.py have a path to python executable hardcoded with hashbang on the firstline? – Dima Chubarov Jul 08 '15 at 06:21
  • If only I knew where SLURM dumped the cores. They're not in my working directory, and I'm still waiting to hear back from the HPC person. I've actually sorted out why the core dump is happening, and it has to do with trying to import a recently installed module. It works fine on the login node but not on the compute node. I'm not sure at this point if the arguments are a problem or not. The python script does have the path to the executable hardcoded with hashbang. – Jiffy Jul 09 '15 at 06:21

3 Answers3

1

The problem was the node where my job was sent. I managed to check in which node my job run without errors with the command:

sacct --format=JobID,"AllocCPUS,Node,JobName%20,MaxVMSize,MaxRSS,ReqMem,Start,End"

I identified the proper node and then switch in my .sh with:

#SBATCH -w, --nodelist=compute124
gissemari
  • 11
  • 2
0

This may seem like a silly question, but is the pythonscript.py executable?

Also have you tried

python pythonscript.py arg1 arg2

Alternately, you might be able to change

#!/bin/bash

to

#!/bin/python

or the appropriate path to the python version you want to use.

Matt
  • 545
  • 3
  • 16
  • 1
    Not a silly question at all. Yes, it's executable. I might actually end up deleting this question, because I've discovered where the illegal instruction is coming from, and it's not what I thought it was. It turned out to be a problem with a newly installed module on the compute node (works fine on the login node). Once that problem is fixed and I'm sure that the arguments are no longer a problem, I'll remove this question. Thanks for your response. – Jiffy Jul 09 '15 at 02:20
0

I use the following and I can add any number of arguments.

#!/bin/bash
#SBATCH --cpus-per-task=1        # number of cores

cd $SLURM_SUBMIT_DIR
pwd

python $SLURM_SUBMIT_DIR/python.py HumptyDumpty.txt newhumpty.txt ad.txt