>>
 >>

Anaconda Setup

Anaconda is a great package management tool for, especially for Python based AI projects. Package management is required due to the differing package dependencies for various AI tools and libraries. Ananconda allows you to create different environments which have a different set of packages and versions.

For example you man need CUDA 11.8 and torch 1.8 for a particular application and another man require CUDA 12.4 and torch 2.0.1. Having separate virtual environments allows this different configurations to exist on the same machine. The following instructions will assist in installing and using Ananconda.

Installing conda:
Conda Installation Guide

Creating a virtual environment (optional python version shown in braces):
conda create -n [env_name] {python=3.11}

Listing virtual environments:
conda env list

Removing a virtual environment:
conda remove --name [env_name] --all

Activating a virtual environment:
source activate [env_name]

Deactivating a virtual environment:
conda deactivate

Exporting a virtual environment (saved to enviornment.yaml):
conda env export > environment.yaml

Creating a virtual environment from a file (imported from enviornment.yaml):
conda env create -f environment.yaml

Installing packages:
conda install [package_name]
This will install the latest version of the package available in the conda channels. I have found that installing packages with PIP usually provides newer package versions and results in less conflicts so I recommend it over conda for installations. Simply replace conda in the command above with pip.

To install a particular version of a package use:
conda install [package_name]=[version]

List installed packages:
conda list
This will also list packages installed with pypi (via the pip install commdand). These packages will have pypi listed as the channel.

Adding channels:
Channels allow for additions package sources. One of the most common is conda-forge which will be reqiuired for some packages.
conda config --add channels conda-forge

If you are running into conflicts with the base conda packages and system packages you can configure conda to not run the base environment when opening the terminal (command below). Another option would be to not install any packages in the base enviornment.
conda config --set auto_activate_base false

Tips for Package Management

Sometimes you will run into version conflicts with packages and binaries when trying to install and compile applications in Conda environments. If this occurs the first thing to check is the path that is being used for a particular application. This can be done with the which command. For example if you have a conflict with the gcc version you can use this command to check which gcc is being used: which gcc

If the outputted path is /usr/bin/package it means conda is targetting the default system installation (probably due to that particular package not being intstalled in the current conda environment). If the path is /home/user/miniconda3/envs/env_name/bin/package then the package being targeted is installed in the conda environment. If you need to install another version of the package use conda install [package_name]=[version].