From the Eye of Depth course.
Note 1: The purpose of installing anaconda is to create a virtual environment (conda is used); the purpose of installing pycharm is to use it as a compiler; the purpose of installing cuda is to install GPU (only the CPU can be omitted).
————————————————————————————————————————————
Notes 2: The third step of the above installation is very important, pay attention to the check, because it refers to adding anaconda to the system environment variables.
——————————————————————————————————————————————
国内可用Anaconda 源的镜像站及换国内源方法:
Conda
#中科大
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
#清华
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/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
----------------------------------------------------------------------------
conda config --show查看用的哪个源
conda config --remove-key channels删除正在使用的源
Note 3: Copy the source of the University of Science and Technology of China or Tsinghua into the command line, the purpose is to use conda to download the installation package faster.
——————————————————————————————————————————————
conda create -n pytorch_1.4.0_cpu python=3.7#CPU
conda create -n pytorch_1.4.0_gpu python=3.7#GPU
Note 4: This command is to create a name for the virtual environment of pycharm, in which pytorch_1.4.0_cpu is custom (the name is easy to remember, shorter is better). During this download process, if it is very slow, you can switch the mirror source back and forth (remember to delete first when switching, there is a delete command above). As shown in the figure below, there can be many virtual environments, and pytorch must be downloaded in the corresponding virtual environment.
------------------------------------------------
then they You can use conda to view the created virtual environment.
conda activate pytorch_1.4.0_cpu#打开该环境
conda deactivate#退出当前环境
conda info --envs#查看所有的虚拟环境
You can find it under envs in the anaconda installation directory.
————————————————————————————————————————————
Notes 5: Choose the latest previous version (professional) to download, the activation steps are detailed at: https://shimo.im/docs/GJTqgHqh6kGYkKKY/read.
————————————————————————————————————————————
Notes 6: Find the newly created virtual environment in pycharm (search by directory, basically in the envs of the anaconda installation directory).
Then open pycharm, there is a terminal at the bottom of the page, which is equivalent to the command line of the system. (Pause here first, don’t close)
conda activate pytorch_1.4.0_cpu
————————————————————————————————————————————
Notes 7: If GPU is not installed, this step can be omitted.
cuda official website: https://developer.nvidia.com/cuda-92-download-archive (if the installation fails, choose a custom installation when installing again, and use Visual Studio Intergration)
Then, check whether the installation is successful (site to installation In the directory, check nvcc -V), as follows:
————————————————————————————————————— —————————
Note 8: Here is to install cudnn, registration is required, address: https://developer.nvidia.com/cudnn, and then click download. (To correspond to cuda version 10.1)
Finally, verify whether the installation is successful (cd to the installation directory, check the two bandwidthTest.exe deviceQuery.exe):
————————————————————————— ——————————————————————— After
installing cuda and cudnn, copy the three files of cuda to cuda. (Note that it is not a direct copy) as follows:
———————————————————————————————————————— ——————
Note 9: Installation website: https://pytorch.org/get-started/locally/
——————————————————————— ———————————————————————
Note 10: Search the selected website directly, and use the shortcut key Ctrf+F to search in the website.
CPU version: search and download two files, respectively as follows:
GPU version: search and download two files, respectively as follows:
Note 11: CPU starts with cpu; GPU starts with cu. Both must download torch and torchvision.
————————————————————————————————————————————
Open Return If pycharm is not closed, click on the terminal at the bottom of the page to activate the cpu virtual environment.
conda activate pytorch_1.4.0_cpu
cd C:\Users\YUE123\Downloads
dir
First add the mirror source to speed it up:
#清华
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Start to install torch and torchvision:
pip install torch-1.4.0+cpu-cp37-cp37m-win_amd64.whl
pip install torchvision-0.5.0+cpu-cp37-cp37m-win_amd64.whl
(torch-1.4.0+cpu-cp37-cp37m-win_amd64.whl and torchvision-0.5.0+cpu-cp37-cp37m-win_amd64.whl are to find the name of their installation according to the dir command just now)
—————— ———————————————————————————————————————— If you
think it’s more detailed, just go on Car, I can earn a promotion fee, happy.