Conda
The Miniconda3 modules include only conda, python, and a few other packages. Users can use either mamba (preferred) or condo to install packages in their own conda environment.
Accessing Conda
To access the Conda command, load either a miniconda3 or a miniforge module. For example.
Conda Initialization
Users need to initiazlie conda in their ~/.bashrc. This is a one-time operation.
1. Delete Existing Intitialization Commands in ~/.bashrc
If you have initialized conda before via an old miniconda or anaconda module, you need to delete the initialization commands from your ~/.bahsrc. Below is an example of the initialization commands in ~/.bashrc to delete:
2. Exit Your Current Oscar Connection
3. Start a New Oscar Connection and Initialize Conda
Start a new Oscar connection, and run the following command n a terminal
If your default shell is NOT bash, you need to run conda init <my_default_shell> where <my_default_shell> should be replaced with your default shell, e.g., zsh.
Conda Environment
A user may install all needed software packages for a project in a conda environment. A conda environment can be
shared among all users if the environment is installed in a shared directory
private to one user if the environment is installed in a user's private directory
The command 'conda info' shows important configurations for conda environment.
Below are some important configurations:
envs directories
: a list of directories where a conda environment is installed by default. In the output of 'conda info' above, the first default directory to install a conda environment is a $HOME/anaconda.package cache
: a list of directories where downloaded packages are stored.
Create a New Conda Environment
To create a new conda environment in a default directory, run the following command:
To create a new conda environment in a different directory, run the following command:
Activate a Conda Environment
After creating a conda environment, users can activate a conda environment to install or access packages in the environment via the following command.
The commands above will only work if:
A conda environment with the specified name (
conda_environment_name
in the example) existsThe appropriate anaconda module has been loaded (if you are unsure about this one, consult this documentation)
If you need to activate a conda environment in a bash script, you need to source the conda.sh as shown in the following example bash script:
Do NOT activate a conda environment before submitting a batch job if the batch job activates a conda environment. Otherwise, the batch job will not be able to activate the conda environment and hence fail.
After installing packages in an active environment (instructions below), you do not need to load or install those packages in the bash script; any packages installed in the conda environment (before the script even starts) will be available through the environment after it is activated (line 4 in the code above).
To deactivate a conda environment, simply use the following command:
Install Packages in an Active Conda Environment
To install a package, we need to first activate a conda environment, and then run
The "=version" is optional. By default, conda install a package from the anaconda channel. To install a package from a different channel, run conda install
with the -c
option. For example, to install a package from the conda_forge channel, run
Delete a Conda Environment
To delete a conda environment, run
Remove Caches
Conda may download lots of additional packages when installing a package. A user may use up all quota due to these downloaded packages. To remove the downloaded packges, run
Mamba
To access mamba, load a miniforge module:
Mamba is a drop-in replacement of conda, and is faster at resolving dependencies than conda. For all conda commands, conda
can be replaced with mamba
. More details can be found in Mamba User Guide.
Last updated