pythonslurmsbatch

How to activate a specific Python environment as part of my submission to Slurm?


I want to run a script on cluster (SBATCH file).

  1. How can activate my virtual environment (path/to/env_name/bin/activate).

  2. Does I need only to add the following code to my_script.sh file?

    module load python/2.7.14 source "/pathto/Python_directory/ENV2.7_new/bin/activate"


Solution

  • Yes. Just make sure to insert those lines after the SBATCH ... lines and before any use of python.