Reputation: 407
I want to run a python script using the command spark-submit on a slurm cluster using the commands srun and sbatch. When I run my current script it runs until the end and the end status is COMPLETED. However, looking at the history-server of spark, I can see that all job ids are named "local...". When I check the environment variables, "spark.master" is always set to local[*]. I tried a lot of things and read a lot of documentation, but I could not found how to use multiple workers.
Here is my config:
#SBATCH --time=00:05:00
#SBATCH --nodes=4
#SBATCH --ntasks=4
#SBATCH --mem=4G
#SBATCH --cpus-per-task=8
#SBATCH --ntasks-per-node=1
module load spark/2.3.0
module load python/3.7
source ~/acc_env/bin/activate
export MKL_NUM_THREADS=1
export SPARK_IDENT_STRING=$SLURM_JOBID
export SPARK_WORKER_DIR=$SLURM_TMPDIR
export SLURM_SPARK_MEM=$(printf "%.0f" $((${SLURM_MEM_PER_NODE} *95/100)))
#start master
start-master.sh
sleep 20
MASTER_URL_STRING=$(grep -Po '(?=spark://).*' $SPARK_LOG_DIR/spark-${SPARK_IDENT_STRING}-org.apache.spark.deploy.master*.out)
IFS=' '
read -ra MASTER_URL <<< "$MASTER_URL_STRING"
echo "master url :" ${MASTER_URL}
NWORKERS=$((SLURM_NTASKS - 1))
and here are the commands I use to launch the workers and the script:
SPARK_NO_DAEMONIZE=1 srun -n ${NWORKERS} -N ${NWORKERS} --label --output=$SPARK_LOG_DIR/spark-%j-workers.out start-slave.sh -m 4g -c ${SLURM_CPUS_PER_TASK} ${MASTER_URL} &
slaves_pid=$!
srun -n 1 -N 1 spark-submit main.py --master ${MASTER_URL} --executor-memory 4g
Upvotes: 2
Views: 733
Reputation: 407
I found the answer. I post it there if someone has the same problem in the future. The problem was the order in which I put the arguments in the srun spark-submit command. You must put the entry point program (main.py here) after the options because I don't know why but it seems that the arguments are discarded after the entry point argument.
Upvotes: 2