How to Install miniforge
-
This guide explains how to install "Miniforge" in the home area of OCTOPUS.
Log in to OCTOPUS and follow the steps below. In this guide, we use /octfs/home/(user_id)/miniforge3 as the directory for installing Miniforge. Please replace it with your own directory as appropriate.
1. Limit the number of threads used by Miniforge.
In environments with a large number of cores, such as the OCTOPUS front-end, Mamba may hang. Please set the following environment variables to limit the number of threads Mamba uses.
|
1 2 |
echo 'export MAMBA_EXTRACT_THREADS=8' >> ~/.bashrc source ~/.bashrc |
2. Download and run the Miniforge installer.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh bash ./Miniforge3-Linux-x86_64.sh # # Follow the prompts displayed to proceed with the installation # # Do you accept the license terms? [yes|no] # → Agree to the terms of use # yes # Miniforge3 will now be installed into this location: # → Specify the installation location # Specify /octfs/home/(user_id)/miniforge3 # Do you wish to update your shell profile to automatically initialize conda? # → Initialize Miniforge # yes |
3. Set the environment variables needed to use Miniforge. This setting is not necessary for subsequent uses.
|
1 2 |
source ~/.bashrc mamba config set auto_activate_base False # Prevent automatic activation of the base environment |
(Note) Installing Miniforge updates ~/.bashrc. However, if conda-related software is already installed, ~/.bashrc may not be updated correctly. In such a case, edit .bashrc, delete the lines from "# >>> conda initialize >>>" to "# <<< conda initialize <<<", and then re-execute "/octfs/home/(user_id)/miniforge3/bin/conda init".
How to use Miniforge
List of virtual environments
-
Displays the list of virtual environments that have already been built.
mamba env list
Name Active Path
───────────────────────────────────────────────
base * /octfs/home/(user_id)/miniforge3
Creating a new virtual environment
-
The following is the procedure for creating a new virtual environment called test-env in the user area.
First, generate the virtual environment test-env.
mamba create --name test-env python=3.10
If you view the list of virtual environments, you will see that test-env has been generated.
mamba env list
Name Active Path
─────────────────────────────────────────────────────────────────
base * /octfs/home/(user_id)/miniforge3
test-env /octfs/home/(user_id)/miniforge3/envs/test-env
Enabling the virtual environment
-
Enable the virtual environment test-env.
mamba activate test-env
Installing software in a virtual environment
-
Install the Python library numpy in the virtual environment test-env. Since communication to the outside world is not possible from a compute node, please make sure to do this on the login node.
mamba install numpy
Disable the virtual environment
- Disable the virtual environment test-env.
mamba deactivate
How to use in OCTOPUS calculation node
Please make the following job script when you enable the virtual environment "test-env" and execute test.py on one CPU node of OCTOPUS.
|
1 2 3 4 5 6 7 |
#!/bin/bash #PBS -q OCT #PBS --group=(group_name) #PBS -l elapstim_req=1:00:00 cd $PBS_O_WORKDIR mamba activate test-env python test.py |
How to change the save location for virtual environments and packages
-
By default, virtual environments and packages are installed in the ~/miniforge3 directory under your home directory. Therefore, creating numerous virtual environments or installing a large number of packages may cause your home directory to exceed its storage capacity.
By setting the virtual environment and package save location to the work area using the following command before creating the virtual environment, you can prevent the home area from exceeding its capacity.
mamba config prepend envs_dirs /octfs/work/(group_name)/(user_id)/mamba_envs
mamba config prepend pkgs_dirs /octfs/work/(group_name)/(user_id)/mamba_pkgs

