Conda is a package manager and environment management system.
Resources¶
- Conda docs
- Conda cheat sheet
- Conda: Myths and Misconceptions
- Conda forge (an alternative distribution for conda)
Installation¶
Miniforge¶
https://
bash Miniforge3-Linux-x86_64.shMiniconda¶
# Download
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# Installation
bash ~/Miniconda3-latest-Linux-x86_64.sh
# Activate
source ~/.bashrcShould you add Conda to the PATH?¶
Prevent conda from activating the base env by default¶
conda config --set auto_activate_base falseWant to change kernel in jupyter?¶
Base environment needs the nb_conda_kernels package.
Every environment needs the ipykernel package.
conda install nb_conda_kernelsUpdating Conda¶
Update base environment¶
conda update condaUpdate all packages of activated environment¶
conda update --allEnvironments¶
Create new environment and switch to it¶
conda create -n name_of_new_env
conda activate name_of_new_envCreate environment with specific python version:
conda create -n name_of_new_env python=3.12Remove environment¶
conda deactivate # only relevant if environment to-be-deleted is activated
conda remove -n name_of_env --all
# alternative: conda env remove -n name_of_envList all environments¶
conda env listAdding channels to environment¶
Activate the environment, then:
conda config --env --add channels conda-forgeSharing an environment¶
This can be useful if you want to document the package versions for a project or if you are collaborating with other people so they can work with the same environment.
conda env export > environment.ymlTo exclude packages that were installed into the environment as a dependency add the flag --from-history.
This can help for cross-platform compatibility, because conda will figure out platform-specific dependencies.
However, this will not document the version of a package if the version was not explicitly stated when installing.
conda env export --from-history > environment.ymlTo recreate the environment using the yml file:
conda env create -f environment.ymlArchived¶
Deep learning environment¶
Prereq:
sudo apt-get install libhdf5-serial-dev # for saving keras models efficiently
sudo apt install graphvizconda create -n deeplearn
source activate deeplearn
conda install tensorflow-gpu
conda install matplotlib
conda install opencv # needed for some examples
conda install pydot # graphviz
conda install pillow # python imaging library
conda install cython # Why?
conda install ipykernel # for kernel selection in jupyter
# conda install matplotlib PyYAML opencv-python pydot pillow cythonCheck tensorflow gpu¶
import tensorflow as tf
tf.test.is_gpu_available(
cuda_only=False,
min_cuda_compute_capability=None
)