“This is the fourth day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

Machine learning environment construction

  1. Recommend installing acaconda www.anaconda.com/products/in…
  2. Common Commands

Create a new virtual environmentConda create --name my__test python=3.7Create a my__test

Activate the virtual environment

activate my_test

## View the existing virtual environment

conda env list

## Switch to the desired virtual environment. Here I switch to my_test

conda activate my_test

Install the ipykernel in the current environment

conda install ipykernel

## Conda clone environment

conda create --name B --clone A

## conda deletes the environment

conda remove --name B --all

Conda renames the environment

conda create --name B --clone A
conda remove --name A --all



Copy the code
  1. In the source

Ps: tsinghua university image: mirrors.tuna.tsinghua.edu.cn/help/anacon…

  • Look at the source

conda config --show-sources

channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main -  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - defaults show_channel_urls:true

Copy the code
  • Add the warehouse

Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/pk… Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/pk… conda config –set show_channel_urls yes

  • A third party source

Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/cl… Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/cl… Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/cl… Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/cl… Conda config – add channels mirrors.tuna.tsinghua.edu.cn/anaconda/cl…

  1. Cuda and CUDNN download

Cuda each version of the download developer.nvidia.com/cuda-toolki… Download cudnn developer.nvidia.com/rdp/cudnn-d… The nvidia driver’s official website www.nvidia.com/Download/in…

  1. Check out the pyTorch website for recommended versions

Pytorch.org/get-started… In the command symbol window, enter nvidia-smi to view the Driver Version

Note: Drivers are backward compatible, which determines the highest version of CUDA and CUDAToolkit that can be installed.

CUDA and its PyTorch counterpart (see official website)

  1. test
import torch

print(torch.cuda.is_available())
# cudA is available;

print(torch.cuda.device_count())
# return gpu count;

print(torch.cuda.get_device_name(0))
The device index starts at 0 by default.

print(torch.cuda.current_device())
# return current device index;

print(torch.__version__)

print(torch.version.cuda)

Copy the code