Running an Anaconda script as a Slurm job♯
An example for running a Python script as a job using Anaconda on a GPU node.
Code♯
Python script♯
We'll use a simple Python Hello World script as an example.
anaconda.py
#!/usr/bin/env python3
import sys
import os
print("hello, world")
Job script♯
Now we'll add a Slurm job script named anaconda.sh
in the same directory as anaconda.py
that directs Slurm to use 1 GPU node with a wall time of 30 minutes.
anaconda.sh
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --partition=gpu
#SBATCH --gres=gpu:2
#SBATCH --mem=4G
#SBATCH --time=00:30:00
module load python/anaconda3
. ~/.bashrc
python3 ./anaconda.py
Run♯
Job submission♯
Make the Python script executable:
[juser@picotte001]$ chmod +x anaconda.py
Submit the job script using sbatch
:
[juser@picotte001 ~]$ sbatch anaconda.sh