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 mamba install ____
or pip install ____
.
If you have an environment.yml
file and want to import that, check out this section of the Conda page.
mamba 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.
Mamba can detect if there is a GPU available on the computer, so the easiest approach is to run the mamba install
command in a GPU session. Alternatively, you can run mamba install
on any node, or if a cpu-only pytorch
package was already installed, by explicitly requiring a GPU version of pytorch
when running mamba install. E.g. mamba 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
mamba activate my_env
module load conda
mamba activate /blue/mygroup/share/conda/envs/my_env
Example of installing PyTorch
From the PyTorch Installation page, use:
mamba install pytorch torchvision torchaudio cudatoolkit=12.1 -c pytorch
When you run that command, mamba
will look in the repositories for the specified packages and their dependencies.
mamba
will list the packages it will install and ask you to confirm the changes. Typing 'y' or hitting return will proceed; 'n' will cancel.
Finally, mamba
will summarize the results.
Example of installing Tensorflow
If you want Tensorflow instead of Pytorch, an example command would be:
mamba install tensorflow
Or for a specific version on Tensorflow:
mamba install tensorflow=2.16
Install Additional Packages¶
Use mamba 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