Installing Packages with mamba and pip
Once you have an environment created, you are ready to install packages into it.
There are a few ways to do this. You can install things one-by-one with either conda install ____
or pip install ____
.
If you have an environment.yml
file and want to import that, check out this section of the Conda page.
conda install
packages¶
If you plan on using a GPU
To make sure your code will run on GPUs install a recent cudatoolkit
package that works with the NVIDIA drivers on HPG (currently 12.x, but older versions are still supported) alongside the pytorch
or tensorflow
package(s).
See the UFIT-RC provided tensorflow
or pytorch
installs for examples if needed.
Conda can detect if there is a GPU available on the computer, so the easiest approach is to run the conda install
command in a GPU session. Alternatively, you can run conda install
on any node, or if a cpu-only pytorch
package was already installed, by explicitly requiring a GPU version of pytorch
when running conda install. E.g. conda install cudatoolkit=11.3 pytorch=1.12.1=gpu_cuda* -c pytorch
Load the conda
module¶
To get started, be sure to load the conda
module and activate your environment.
module load conda
conda activate my_env
module load conda
conda activate /blue/mygroup/share/conda/envs/my_env
Example of installing PyTorch
Start with installing Python:
conda install python
Pytorch no longer supports conda. From the PyTorch Installation page, use:
pip3 install torch torchvision torchaudio
Example of installing Tensorflow
If you want Tensorflow instead of Pytorch, an example command would be:
conda install tensorflow
Or for a specific version on Tensorflow:
conda install tensorflow=2.16
Install Additional Packages¶
Use conda install
to install any additional packages you need.
Add Packages to Your Environment with pip install
¶
Not everything is available in a conda
channel, and you may need to use pip
to install some packages.
As long as your environment is active (look for the environment name in the prompt (my_env) [username@login8 ~]$
), pip
will install packages within the environment, not your home directory.
pip install package_name