Creating an environment using Mamba on LANTA-HPC
This article will guide you to create the environment using Miniconda on a LANTA HPC system. An overview of the content can be found in the table of contents below for immediate visualization of the interesting parts.
Using Mamba on LANTA HPC
Load Mamba module
Use the
ml av Mamba
command to see which version of Mamba is available on the LANTA HPC system.Use the
ml Mamba/xx.xx.x
command to load the Mamba version that you want to use. If you don't specify a version, the default version (D) is loaded, which is Mamba/23.11.0-0.
username@lanta:~> ml av Mamba
---------------------- /lustrefs/disk/modules/easybuild/modules/all -----------------------
Mamba/23.11.0-0 (D)
Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
username@lanta:~> ml Mamba/23.11.0-0
Unload Mamba module
Use the module unload Mamba
command to unload the Mamba.
username@lanta:~> module unload Mamba
Use the module purge
command to unload all currently loaded modules.
username@lanta:~> module purge
Before you use the module unload Mamba
or module purge
command, you must deactivate your environment with the conda deactivate
command.
Activate your environment
Use the
conda env list
command to view a list of your environments.If you want to activate your environment such as TensorFlow-2.6.0, you can use the
conda activate tensorflow-2.12.1
command.
Deactivate your environment
Use the conda deactivate
command to deactivate your environments.
Creating the environment in the user’s home
Create the environment
Use the conda create -n myenv
commands to create the environment with myenv name.
Create the environment with a specific version of the packages
Use the conda create -n myenv python=3.9
commands to create the myenv environment with a specific version of python.
Use the conda create -n myenv python=3.9 numpy=1.23.5
commands to create the myenv environment with a specific version of python and numpy.
Creating the environment in the project’s home
Specify a location for the environment
Use the conda create --prefix /your project directory/envs
commands to create the environment on the specific location.
Specify a location for the environment with a specific version of a package
Use the conda create --prefix /your project directory/envs python=3.9
commands to create the environment with a specific version of a package on a specific location.
Activate your environment in the project’s home
If you want to activate your environment in the project’s home, you can use the conda activate /your project directory/envs
command.
Creating the environment from an requirements.yml file
A simple requirements.yml file
In the requirements.yml file, you need to specify the environment name and packages that you want to use.
Create the environment from the requirements.yml file in the user’s home
Use the conda env create -f requirements.yml
commands to create the environment from the requirements.yml file in the user’s home.
Create the environment from the requirements.yml file in the project’s home
Use the conda env create -f requirements.yml --prefix /your project directory/envs
commands to create the environment from the requirements.yml file on the specific location.
Removing the environment
Remove the environment in the user’s home
If you want to remove the myenv environment, you can use the conda remove --name myenv --all
command.
Remove the environment in the project’s home
If you want to remove the environment in /your project directory/envs
, you can use the rm -rf /your project directory/envs
command.
Related articles