Quick start:
Install Conda and Python Environment This document describes the installation method of the AI algorithm's conda package management tool, basic python environment, and GPU driver.
It is intended to build a basic AI development environment and enable the reader to quickly start AI commissioning.
Target user
AI developer
Detailed course
Basic environment
Project | Version |
---|---|
Operating system | ubuntu20.04 |
Architecture | x86 |
Install conda
Most algorithm environments require package support from conda sources, and environments among different algorithms need to be isolated to avoid conflicts, so conda is used to build virtual environments. Basic packages such as python and pip can be installed directly through conda, which reduces the installation time.
- Download the conda package.
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
- Add the executable permission.
chmod +x ./Anaconda3-2021.11-Linux-x86_64.sh
- Install the sh file.
During the process, you will be prompted to enter configuration parameters such as the installation location. You can simply press [Enter] to use the default settings, which will install in the ~/anaconda3 directory for the current user.
bash Anaconda3-2021.11-Linux-x86_64.sh
- Initialize the conda.
By the last installation step of the interaction:
Or by the command line after the installation is complete
~/anaconda3/bin/conda init
- Activate the conda environment.
source ~/.bashrc
conda -V
- Configure conda to a domestic source, such as the Tsinghua source.
TIP
Other sources can be customized.
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
- Activate the source configuration.
conda update -n base -c defaults conda
At this point, the conda is installed successfully, and it is available to configure and manage the python.
Install python
- After the conda installation is complete, configure and install the python through conda.
python3.8 is recommended.
conda -V
conda create --name py38 python=3.8 -y
- Switch to the new python environment and check the python version and pip version.
conda activate py38
python -V
pip -V
- Modify the pip source as a domestic source, such as the Tsinghua source to speed up the package download.
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
TIP
Other sources can be customized.
- Upgrade the management tool pip for the python package to the latest version.
pip install -U pip