1. Download Anaconda installation package, official website address, Tsinghua source address.
After downloading from the official website to the local, you can upload the installation package to the server through file transfer, and use the Tsinghua source address to directly use wget to download the required version, for example:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Linux-x86_64.sh
2. Install Anaconda
bash Anaconda3-2022.05-Linux-x86_64.sh
Then, Enter
Accept the license terms, yes, then information about the installation location of Anaconda3 will be displayed.
Follow the prompts to activate the basic environment of conda
eval "$(/home/cxcai/anaconda3/bin/conda shell.bash hook)" conda init
conda info # View conda related information
3.conda change source
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes # Display channel address when setting search
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/free/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
Note: restore the original channel command
conda config --remove-key channels # restore channel
4. Install pytorch
- Query cuda version
nvidia-smi
- Install the corresponding pytorch version, check the pytorch version corresponding to cuda on the official website, or use
conda search pytorch
to query the pytorch version that can be installed (downward compatible)
- conda creates and activates a virtual environment
conda create -n envpytorch python==3.10 # Create envpytorch virtual environment and configure python3.10 source activate envpytorch # activate the virtual environment conda activate envpytorch # enter the virtual environment conda deactivate # Exit the virtual environment
- Install pytorch, torchvision, torchaudio, cudatoolkit in the created virtual environment
- Check if the installation is successful
- Install matplotlib, pandas, numba, seaborn and other libraries
conda install matplotlib conda install pandas conda install numba conda install seaborn
Install TensorFlow
- Also create and activate the virtual environment trf
conda create -n trf python==3.8.16 source activate trf conda activate trf conda deactivate trf conda env list # View all virtual environments
- Check the corresponding tensorflow-gpu version, or use
conda search tensorflow-gpu
- Install tensorflow-gpu2.4.1
- After the installation is complete, test whether tensorflow is installed successfully
python
import tensorflow as tf print(tf.__version__) print(tf.test.gpu_device_name()) print(tf.config.experimental.set_visible_devices) print('GPU:',tf.config.list_physical_devices('GPU')) print('CPU:',tf.config.list_physical_devices(device_type='CPU')) print(tf.config.list_physical_devices('GPU')) print(tf.test.is_gpu_available()) # output the number of GPUs available print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
It can be seen that there is an error in this installation
The reason for the error is that numpy does not have an object attribute. After consulting the materials, it is found that the numpy version is too high, so choose to reduce the version
conda install numpy==1.23.4
Test again whether the installation was successful
The installation is successful! ! ! ! ! ! ! ! ! ! ! ! ! !