1. Anaconda download and installation
Download address: Enter the anaconda official website, Anaconda | The World's Most Popular Data Science Platform
After the download is complete, click Install. The specific operations are as follows:
It is recommended to check the first option, which will automatically configure the anaconda environment in the system.
After the installation is complete, check whether the environment variables of your computer are configured successfully. Right-click this computer => Properties => Advanced System Settings => Path
Because during the anaconda installation process, it is just user and not all users, so check whether the path under the user has these five environment variables.
D:\anaconda
D:\anaconda\Library\name-w64\bin
D:\anaconda\Library\usr\bin
D:\anaconda\Library\bin
D:\anaconda\Scripts
2. Install and configure the pytorch environment
1. Create a virtual environment
conda env list
Check out the several corresponding environments under conda. I already have two. One is the base environment that comes with it when installing anaconda, and the other is pytorch that I installed later.
conda create -n pytorch_gpu python=3.6
Create a new pytorch_gpu environment, in which the python version selected is version 3.6 (later it was found that version 3.6 did not correspond to the cuda version, so python3.7 version was installed instead).
Select Y to wait for the python environment to be installed automatically.
After waiting for the installation to complete, enter in the console
conda activate pytorch_gpu
We can enter this environment and enter python in this environment. If the following picture appears:
It means that our environment has been created successfully, and the next step is to install pytorch.
2.pytorch installation
Our installation method this time uses online installation. The installation URL is the pytorch official website.
PyTorch An open source machine learning framework that accelerates the path from research prototyping to production deployment. https://pytorch.org/ If the installation of some packages fails, you can also use offline installation. After downloading the installation package through the mirror, install it. For the specific process, please refer to this article https://blog.csdn.net/qq_32863549/article/details/107698516?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167047570316782414986134%2522%252C %2522scm%2522%253A%252220140713.130102334 ..%2522%257D&request_id=167047570316782414986134&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-107698516-null-null.142^v68^pc_rank_34_que ryrelevant25,201^v4^add_ask,213 ^v2^t3_control1&utm_term=pytorch%E5%AE%89%E8%A3%85&spm=1018.2226.3001.4187https://blog.csdn.net/qq_32863549/article/details/107698516?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167047570316782414986134%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=167047570316782414986134&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-107698516-null-null.142%5Ev68%5Epc_rank_34_queryrelevant25,201%5Ev4%5Eadd_ask,213%5Ev2%5Et3_control1&utm_term=pytorch%E5%AE%89%E8%A3%85&spm=1018.2226.3001.4187
Before installing pytorch, you should first check whether your computer supports CUDA. Generally speaking, any NVIDIA graphics card can be accelerated by GPU. can be entered in the console
nvidia—smi
The version I support is before version 11.4, so choose the corresponding version
I finally chose version 1.12 of pytorch and version 11.3 of cuda,
If you install the instructions from the official website, the speed is very slow and takes a long time. At this time, you can use the mirror to download. Please refer to this article for details (you can also download it on the mirror website and then install it offline). The installation speed of Pytorch in Anaconda is too slow. Solution Method_Snail is Tingyu's Blog-CSDN Blog_anaconda pytorch installation is too slow 1. Problem After creating a new environment in Anaconda, I want to install Pytorch directly on the GUI, but the speed is extremely slow. 2. Solution 1. Click the arrow on the right side of the environment to open the terminal of the current environment. 2. Add mirror. Add the mirror URL in the pop-up terminal window. Enter the code as follows: conda config --add channels https://mirrors. tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/conda config --add channels https://mirrors.tuna.tsing https://blog.csdn.net/omg_orange/article/details/108652090?ops_request_misc=&request_id =&biz_id=102&utm_term=anaconda%E5%AE%89%E8%A3%85pytorch%E9%80%9F%E5%BA%A6%E6%85%A2&utm_medium=distribute.pc_search_result.none-task-blog-2~all ~sobaiduweb~default-0-108652090.nonecase&spm=1018.2226.3001.4187
Successful installation can verify torch
3.Install cudnn
There are two ways to find the corresponding version of cudnn, the first is to find it on the official website of NVIDIA
cuDNN Archive | NVIDIA Developer Explore and download past releases from cuDNN GPU-accelerated primitive library for deep neural networks. https://developer.nvidia.com/rdp/cudnn-archive The second is to directly enter the search command in the console
conda search cudnn
conda search cudnn --info
可以查看准确的版本及其下载源
Find your corresponding version
conda search cudnn=8.2.1 --info 可以查找8.2.1的对应下载源
conda install cudnn=8.2.1 -c +在查找中提供的下载地址
Downloading through the mirror is faster, verify it after the download is successful.
If this is the case after running, the configuration is successful.
4.opencv installation
The environment configuration of opencv this time adopts offline installation.
First, download the corresponding version of the whl file on the mirror website. The mirror website corresponds as follows:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv (foreign mirror network)
https://pypi.tuna.tsinghua.edu.cn/simple/opencv-contrib-python/ (Tsinghua Mirror Network)
cp37 means python3.7 version, then the first one is macos system, the second and third are linux systems, the fourth and fifth are win systems corresponding to 32-bit and 64-bit respectively. Mine is a 64-bit system. If I don’t know, right-click on My Computer and select Properties.
I installed python 3.7, and my computer is a 64-bit windows operating system. I choose the corresponding opencv version according to my needs.
Here's what I chose:
Place the downloaded whl file in the site-packages folder under the Lib folder in the anaconda directory
Then open the control window and cd to the site-packages folder in the pytorch_gpu environment.
(Note that if the cd command is run across disks, you need to add /d at the end)
After cd to site-packages, install opencv through pip install
pip install +whl文件名字
Verify opencv installation
The installation is successful.
3. Configure the pytorch environment in pychrm
Select the setting option under the file file
Select the python file in the corresponding environment.
The environment is as shown in the figure, click ok, then the configuration is successful.
Verify as follows:
Enter the following command in the python console in pycharm, and if it runs as shown in the figure, it means that the operation is successful.