How to Install miniforge
-
This guide explains how to install "miniforge" in the work area of SQUID.
1. Log in to SQUID and follow the steps below. In this guide, we use /sqfs/work/(group_name)/(user_id)/miniforge as the directory for installing Miniforge. Please replace it with your own directory as appropriate.
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 /sqfs/work/(group_name)/(user_id)/miniforge # Do you wish to update your shell profile to automatically initialize conda? # → Initialize Miniforge # yes |
2. Set the environment variables needed to use Miniforge. This setting is not necessary for subsequent uses.
1 2 3 4 5 |
/sqfs/work/(group_name)/(user_id)/miniforge/bin/conda init # If you chose yes to initialize Miniforge during installation, this is unnecessary source ~/.bashrc conda config --add envs_dirs /sqfs/work/(group_name)/(user_id)/conda_env conda config --add pkgs_dirs /sqfs/work/(group_name)/(user_id)/conda_pkg conda config --set auto_activate_base False |
(Note) Executing conda init 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 conda init.
(Note) Please note that "default" channel cannot be used. If you have it registered as a channel, please remove it by executing the command conda config --remove channels defaults.
How to use
List of virtual environments
- Displays the list of virtual environments that have already been built.
conda info -e
# conda environments:
#
base /sqfs/work/(group_name)/(user_id)/miniforge
Creating a new virtual environment
- The following is the procedure for creating a new virtual environment called test-env in the user area.
First, specify the conda_env directory under the work area as the destination of the virtual environment. (If you do not specify any directory, the virtual environment will be created in the .conda directory under the home area, which may overflow the capacity.)
conda config --add envs_dirs /sqfs/work/(group_name)/(user_id)/conda_env
conda config --add pkgs_dirs /sqfs/work/(group_name)/(user_id)/conda_pkg
Generate the virtual environment test-env.
conda create --name test-env python=3.8
If you view the list of virtual environments, you will see that test-env has been generated.
conda info -e
# conda environments:
#
test-env * /sqfs/work/(group_name)/(user_id)/conda_env/test-env
base /sqfs/work/(group_name)/(user_id)/miniforge
Enabling the virtual environment
- Enable the virtual environment test-env.
conda activate test-env
Installing software in a virtual environment
- We 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.
conda install numpy
Disable the virtual environment
- Disable the virtual environment test-env.
conda deactivate
Example: How to Use Pytorch with Miniforge
-
Create and activate the virtual environment pytorch-env.
conda create --name pytorch-env python=3.12
conda activate pytorch-env
Refer to the official Pytorch page to install Pytorch using the Conda Package compatible with CUDA 11 series.
As of August 2024, the command is as follows:
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
How to use in SQUID calculation node
Please make the following job script when you enable the virtual environment "test-env" and execute test.py.
1 2 3 4 5 6 7 8 |
#! /bin/bash #PBS -q SQUID #PBS --group=(group_name) #PBS -l elapstim_req=1:00:00 cd $PBS_O_WORKDIR source ~/.bashrc conda activate test-env python test.py |