HomeBlogOthersHow to Install PyTorch on Window 10 / 11 [Nvidia AMD GPU & CPU]

How to Install PyTorch on Window 10 / 11 [Nvidia AMD GPU & CPU]

cover_img
  1. Prerequisites for Installing PyTorch
  2. Navigating the PyTorch Homepage
  3. Selecting the Compute Platform
  4. Checking CUDA Version
  5. Downloading CUDA Toolkit
  6. Installing CUDA
  7. Installing Visual Studio
  8. Completing the CUDA Installation
  9. Finalizing PyTorch Installation
  10. Verifying the PyTorch Installation
  11. FAQ

Prerequisites for Installing PyTorch

Before installing PyTorch, ensure that Python and pip are installed on your machine. If you haven't installed them yet, refer to the official documentation for guidance. Once you have Python and pip set up, you can proceed with the installation of PyTorch.

Navigating the PyTorch Homepage

To begin the installation process, visit the official PyTorch website. Scroll down to find the installation options. Select the stable build of PyTorch, which is currently version 2.1.1. Choose your operating system; for instance, if you are using Windows, select that option. For the package, if you do not have Conda, leave it set to pip. The language should remain as Python.

Selecting the Compute Platform

The compute platform refers to the type of graphics card you have. If you possess an Nvidia graphics card, select the appropriate CUDA version. For AMD graphics cards, choose ROCm. If your system lacks a GPU, opt for the CPU option. Note that the AMD graphics card option is unavailable for Windows users; it requires a Linux operating system.

Checking CUDA Version

Before executing the pip install command, it's essential to check which version of CUDA is installed on your system. Open PowerShell and enter the command 'nvcc --version'. If CUDA is not installed, you will need to download it from the Nvidia website.

Downloading CUDA Toolkit

To install CUDA, search for 'install CUDA 12.1' in your browser and click on the first result from Nvidia. Select your operating system, architecture (x86_64), and version of Windows. Choose the 'exe local' installer type and ensure you have at least 3.1 GB of free space before starting the download.

Installing CUDA

Once the CUDA toolkit has been downloaded, navigate to your downloads folder and open the executable. You may need to refresh your page to see the download. Double-click the executable, allow it through your user account control, and choose the extraction path. The installer will check system compatibility; agree to the license agreement and proceed with the recommended installation.

Installing Visual Studio

During the CUDA installation, you may encounter a message indicating that there is no supported version of Visual Studio. To resolve this, you need to install Visual Studio. Search for 'Visual Studio' in your browser and download the Community Edition, which is free. After downloading, open the installer and select the Python development package along with any other packages you may need.

Completing the CUDA Installation

After installing Visual Studio, return to the CUDA installation. Open the CUDA 12.1 executable again, choose the extraction path, and proceed with the installation. Once the installation is complete, verify the CUDA version by running 'nvcc --version' in PowerShell.

Finalizing PyTorch Installation

With CUDA successfully installed, you can now return to the PyTorch installation. Copy the installation command and paste it into PowerShell. After executing the command, you should see a confirmation of the successful installation of PyTorch on your Windows 10 or 11 operating system.

Verifying the PyTorch Installation

To ensure that PyTorch is functioning correctly, run a couple of commands in PowerShell. Start by typing 'python' to enter the Python environment. Then, import PyTorch by typing 'import torch'. To check if CUDA is available, use the command 'torch.cuda.is_available()'. If it returns true, your installation was successful.

FAQ

Q: What are the prerequisites for installing PyTorch?
A: Before installing PyTorch, ensure that Python and pip are installed on your machine. If you haven't installed them yet, refer to the official documentation for guidance.
Q: How do I navigate to the PyTorch homepage for installation?
A: Visit the official PyTorch website, scroll down to find the installation options, select the stable build of PyTorch (currently version 2.1.1), choose your operating system, and set the package to pip if you do not have Conda.
Q: What should I select for the compute platform during installation?
A: Select the appropriate CUDA version for Nvidia graphics cards, ROCm for AMD graphics cards, or the CPU option if your system lacks a GPU. Note that the AMD option is unavailable for Windows users.
Q: How can I check the CUDA version installed on my system?
A: Open PowerShell and enter the command 'nvcc --version'. If CUDA is not installed, you will need to download it from the Nvidia website.
Q: What steps are involved in downloading the CUDA Toolkit?
A: Search for 'install CUDA 12.1' in your browser, select your operating system and architecture, choose the 'exe local' installer type, and ensure you have at least 3.1 GB of free space before starting the download.
Q: How do I install the CUDA Toolkit after downloading?
A: Navigate to your downloads folder, open the executable, allow it through user account control, choose the extraction path, agree to the license agreement, and proceed with the recommended installation.
Q: What should I do if I encounter a message about Visual Studio during CUDA installation?
A: You need to install Visual Studio. Search for 'Visual Studio' in your browser, download the Community Edition, and select the Python development package along with any other packages you may need.
Q: How do I complete the CUDA installation after installing Visual Studio?
A: Return to the CUDA installation, open the CUDA 12.1 executable again, choose the extraction path, and proceed with the installation. Verify the CUDA version by running 'nvcc --version' in PowerShell.
Q: What are the final steps to install PyTorch?
A: With CUDA installed, return to the PyTorch installation, copy the installation command, paste it into PowerShell, and execute it to confirm the successful installation of PyTorch.
Q: How can I verify that PyTorch is functioning correctly?
A: Run 'python' in PowerShell to enter the Python environment, then type 'import torch'. Use 'torch.cuda.is_available()' to check if CUDA is available; if it returns true, your installation was successful.

Share to

DICloak Anti-detect Browser keeps your multiple account management safe and away from bans

Anti-detection and stay anonymous, develop your business on a large scale

Related articles