Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
doku:python [2023/02/23 11:11] – [Jupyterhub] katrindoku:python [2023/02/23 11:29] – [SLURM] katrin
Line 102: Line 102:
 ===== SLURM ===== ===== SLURM =====
  
-When using slurm it should be enough to include the following code in your slurm batch script. See [[doku:slurm]] for detailed information about slurm in general.+See the following minimal example to use conda with slurm in your batch script (the example assumes that you have the conda init code in your ''~/.bashrc'' file - see below for an alternative). See [[doku:slurm]] for detailed information about slurm in general.
  
 <code bash> <code bash>
 +#!/bin/bash --login
 +
 +#SBATCH --job-name=slurm_conda_example
 +#SBATCH --time 00-00:05:00
 +#SBATCH --ntasks=2
 +#SBATCH --mem=2GB
 +
 spack load miniconda3@4.12.0 spack load miniconda3@4.12.0
 conda activate myenv conda activate myenv
-<code>+which python 
 +python --version 
 +</code> 
 + 
 +Please note the ''--login'' flag to the shell above. This way the shell in the job will be a login shell and thus load your ''~/.bashrc'' file before executing the script code. If cannot or don't want do this you can also just extract the conda init code from your bashrc file and put it into a separate file (e.g. ''conda-init.sh'') that is placed in your home directory and source this file manually in the batch script. 
 + 
 +See the following example: 
 + 
 +<code bash> 
 +#!/bin/bash 
 + 
 +#SBATCH --job-name=slurm_conda_example 
 +#SBATCH --time 00-00:05:00 
 +#SBATCH --ntasks=2 
 +#SBATCH --mem=2GB 
 + 
 +spack load miniconda3@4.12.0 
 +source ~/conda-init.sh 
 +conda activate myenv 
 +which python 
 +python --version 
 +</code> 
  
 ===== JupyterHub ===== ===== JupyterHub =====
  • doku/python.txt
  • Last modified: 2024/03/19 14:24
  • by katrin