1. Win10 installs and detects GPU version Pytorch

The installation steps are as follows:
1. Download/install cuda download link: CUDA Toolkit 11.7 Update 1 Downloads I installed 11.7.1 2. Download cudnn: https://developer.nvidia.com/rdp/cudnn-archive I downloaded 11. x This version is a compressed package. There are three folders bin/include/lib inside. Unzip the folder, copy the files in the decompressed folder to the cuda installation directory, and select overwrite in the corresponding folder. Then add the environment variable by the way.
3. Download and install Anaconda
official download address: https://repo.continuum.io/archive/, download the corresponding version of Anaconda, here use Anaconda3-4.2.0-Windows-x86_64.exe version.
4. Download pytorch torchvision torchaudio cudatoolkit and select the specified version on the PyTorch official website. Start Locally | PyTorch
anaconda to create, and activate the environment as follows:
(1) Open the anaconda prompt as an administrator
(2) Create an environment: conda create -n TorchEnv python=3.9 The 3.9 here is because the python version I use is 3.9. TorchEnv is the name of the environment I created. If an error is reported, see conda to create a virtual environment error Package missing in current win-64 channels
(3) and then activate the environment : activate TorchEnv, if an error is reported, seeError CommandNotFoundError: Command Error: error with command 'activate'. Command not found: 'activate'
(4) Install pytorch torchvision torchaudio cudatoolkit: conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch (copy instructions to prompt Just download it)
Others: During the use of pycharm, I found that my conda reported an error when installing other plug-ins, such as installing visdom. To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page. After checking, the solution is as follows: conda config --add channels conda-forge and you're done.
5. Check whether pytorch is installed successfully

(base) PS C:\Users\chenxuqi> conda deactivate
PS C:\Users\chenxuqi> conda activate ssd
(ssd) PS C:\Users\chenxuqi> python
Python 3.6.12 |Anaconda, Inc.| (default, Sep  9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
0.4.0
>>> print(torch.cuda.is_available())
True
>>>
>>>
>>>

(1) If import torchan error is reported in 【pytorch】错误:No module named ‘typing_extensions‘ 问题解决, the solution is as follows:
Download

https://github.com/python/typing_extensions/blob/main/src/typing_extensions.py

, just copy the file to typing.pythe same level directory of this file. My typing.py directory is:

D:\Anaconda3\envs\TorchEnv\Lib

Exit the compilation environment and enter the python compilation environment again, and it will be successful.
(2) If import torchan error is reported 【pytorch】错误:NameError: name 'sympy' is not defined‘ 问题解决, the solution is as follows:

conda install sympy

(3) The python virtual environment pip under Windows still uses the global pip
The python virtual environment pip under Windows still uses the global pip, which caused me to install a specific module with pip in the virtual environment, but the virtual environment could not read it, and still reported an error: missing For a certain module, please refer to the solution: The python virtual environment pip under Windows still uses the global pip solution.
The core idea is:
a. Activate the virtual environment
b. Use the following command to force the installation to the virtual environment: python -m pip install xxx
(4) Install some modules and report an error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools"
solution See: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools" solution

Guess you like

Origin blog.csdn.net/panchang199266/article/details/126617500