Main Navigation

Secondary Navigation

Page Contents

Contents

Working with Anaconda

Installation of anaconda modules tend to modify .bashrc in the users's HOME directory after a (by conda recommended) conda init. This has the poor effect that interactive login to the cluster is no longer possible. Therefore: Please inspect your $HOME/.bashrc and remove (or comment) all lines that were inserted by the installation process. Use an editor to do so. Comments start with # in the first line.

Instead of letting conda init modify your environment, use the following (in a command window):

# Don't use conda init, but:
. your_anaconda_installation/etc/profile.d/conda.sh
There is a blank after the . and this is required. This will set necessary environment variables in this command window.

To do so in a SLURM-script you may use the following example which as well activates a certain module:

#!/bin/bash
#SBATCH -t 15                # time limit set to 15 minutes
#SBATCH --mem=4096           # 4G of memory are reserved
#SBATCH -J Anaconda          # the job is named Abaqus
#SBATCH --mail-type=END      # an email is send at the end of the job
#SBATCH -n 1                 # 1 processor to be used
#SBATCH -N 1                 # 1 node is used 

module purge				# don't inherit, use clean environment
module load anaconda3/latest
. $ANACONDA_HOME/etc/profile.d/conda.sh
conda activate <your_module>

python3 <your_python_file>

conda deactivate

Some useful commands:

  • conda create -n new_env - creates a new environment
  • conda env list - list your environments
  • conda env remove -n old_env - removes an existing environment