posted on 2023-06-03 19:59 read(693) comment(0) like(11) collect(1)
Determine whether your current computer's graphics card is NVIDIA (N card) or AMD (A card). Pytorch needs to run on an NVIDIA-based graphics card (N card), and A card will not work.
1. Determine what version of CUDA should be installed on the computer.
Enter in CMD:
nvidia-smi
It is found that CUDA version 12.0 can be installed on this machine, and the version is backward compatible, which means that CUDA 12.0 and below versions can be installed , but it is generally not recommended to use the latest version, because other installation packages may not be updated to the corresponding version and can be downloaded. So it is best to choose one or two versions before CUDA 12.0. I choose CUDA 11.6 here, which can be seen from the official website of pytorch (official website: https://pytorch.org/get-started/locally/). The CUDA versions are generally 11.6 and 11.7 (January 9, 2023).
2. Download the corresponding version CUDA 11.6 (official website address: https://developer.nvidia.com/cuda-toolkit-archive)
These three are all CUDA 11.6 installation packages, choose any one and click to download.
3. Select the CUDA installation package corresponding to the platform of this machine. My computer configuration is (Windows 10, 64-bit), and the download will be a bit slow, about 2 G.
4. Open the exe installation package and click Custom Installation
5. If you are installing for the first time, try to select all; if you have uninstalled and reinstalled before, then only check the first CUDA to install, as follows:
6. Try not to choose to install Visual Studio Integration, otherwise there will be problems later
7. Try to use the default path for the installation location. It is best to take a screenshot here, otherwise the subsequent configuration environment variables do not know which folder it is in .
8. Open [Control Panel] - [Programs] - [Programs and Features] to check whether the CUDA program is installed
9. Configure environment variables
Configure 4 environment variables, the variable names are:
CUDA_PATH
CUDA_PATH_V11_6
NVCUDASAMPLES_ROOT
NVCUDASAMPLES11_0_ROOT
The paths are all the paths in the screenshot above, mine is:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
10. Use CMD to check whether CUDA is installed successfully, the command is nvcc --version or nvcc -V
So far, CUDA has been installed successfully.
1. Check the installed CUDA, what is the compatible CUDNN version (official website: https://developer.nvidia.com/rdp/cudnn-archive), this website needs to be registered, register and log in and then you can download it.
I downloaded v8.6.0, which matches CUDA 11.x version.
2. The downloaded file is a compressed package, which is as follows after decompression:
Contains bin, include and lib folders.
3. Copy these three folders (bin, include, and lib) to the folder with the same name as the 8th step of installing CUDA above (it is recommended to copy the contents of the folder to the folder with the same name corresponding to the 8th step of CUDA)
Just copy the contents of the bin, include and lib folders under cudnn-windows-x86_64-8.6.0.163_cuda11-archive after decompression to the bin, include and lib folder.
4. Add environment variables
Add 4 paths inside the Path variable:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\libnvvp
5. Verify whether the configuration is successful,
enter in order in cmd:
cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
cd .\extras\demo_suite
.\bandwidthTest.exe
This means the installation is successful! !
Pytorch is very fragile, you must use Python version + PyTorch version + torchversion version + torchaudio version + CUDA version for one-to-one correspondence! ! My computer is installed with anaconda 3, and the Python version is 3.9. Everyone's version is different, and the things installed are also different.
1. It is best not to go to the official website and use pip to install directly (official website: https://pytorch.org/get-started/locally/), because it is really stuck, and sometimes the mirror will be disconnected halfway due to network problems. It is recommended to use my method to ensure that there will be no mistakes due to mirroring problems or network speed problems!
2. As shown above on the official website, you need to install torch, torchvision and torchaudio (natural language processing is best followed by torchtext), and open the following url (https://download.pytorch.org/whl/cu116)
3. Install torch. Click torch, you will see a bunch of whl files inside, you need to find the most suitable version to download.
First of all, be sure to download the latest version, secondly, it must match your cuda version, then the Python version must also be suitable, then the operating system must also match, and finally, the processor architecture must be suitable.
For example, my computer is cuda11.6, Python 3.9, Windows 10 system 64-bit, then just choose torch-1.12.0+cu116-cp39-cp39-win_amd64.whl, so
my torch version is all after 1.12.0 The package must be installed based on the version corresponding to this version!
4. Install torchvision. The corresponding version is as follows (URL: https://blog.csdn.net/shiwanghualuo/article/details/122860521)
I chose torchvision-0.13.0+cu116-cp39-cp39-win_amd64.whl to download
5. Install torchaudio. The installation version is shown in the table below (URL: https://blog.csdn.net/shiwanghualuo/article/details/122860521)
So I installed torchaudio-0.12.0+cu116-cp39-cp39-win_amd64.whl .
6. Install torchtext. The installation version (URL: https://blog.csdn.net/weixin_45893089/article/details/126533469) is shown in the table below:
I downloaded torchtext-0.13.0-cp39-cp39-win_amd64.whl .
7. Install the four packages of torch, torchvision, torchaudio, and torchtext. I put these four folders into the root directory of the D drive , and enter in cmd:
cd d:\
pip install torch-1.12.0+cu116-cp39-cp39-win_amd64.whl
pip install torchvision-0.13.0+cu116-cp39-cp39-win_amd64.whl
pip install torchaudio-0.12.0+cu116-cp39-cp39-win_amd64.whl
pip install torchtext-0.13.0-cp39-cp39-win_amd64.whl
After the installation is successful, it will display successful!
8. Test whether the installation is successful,
enter in cmd:
python
import torch
torch.cuda.is_available()
If True is displayed, the installation is successful!
Author:kkkkkkkkkkdsdsd
link:http://www.pythonblackhole.com/blog/article/78486/2c6a6e4996dff1395fc5/
source:python black hole net
Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!