简体   繁体   中英

How to send a slurm job using many workers and not just running in local mode?

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

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.

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