Installing PyTorch 1.10.0 on Windows 10/11

PyTorch is a neural network code library.

Note: These instructions also work for PyTorch versions 1.11.x and 1.12.x — just different .whl files (see below).

Prerequisites: A machine with a relatively modern CPU (no older than 8 years old) running Windows 10 or 11, with Python 3.7.6 installed via the Anaconda 2020.02 distribution. See https://jamesmccaffrey.wordpress.com/2022/05/10/installing-anaconda3-2020-02-with-python-3-7-6-on-windows-10-11/.

You must be logged on as a user with full administrative privileges and be connected to the Internet. You can check if you have admin privileges by launching a command shell (cmd) and typing the command “net user”. This will show you your current user name. Then type the command “net user name” and look for the Local Group Memberships entry – it should read “Administrators”.


1. You install PyTorch using a special .whl file and a program called pip (pip has been installed by Anaconda).

Prepare by creating a new directory called PyTorch, preferably in your root C:\ or D:\ directory. In the PyTorch directory, create a new sub-directory named Wheels to hold the .whl install file.


2. You must find the .whl installation file for PyTorch 1.10.0 CPU on Python 3.7.6 for Windows.

Do an Internet search for “pytorch 1.10 cpu windows”. You may need to search a bit. As I write this post, the .whl files were found at:

https://download.pytorch.org/whl/cpu/torch_stable.html

When you find the page, look for file:

torch-1.10.0%2Bcpu-cp37-cp37m-win_amd64.whl

Be very, very careful to get the one and only one correct .whl file — there are 19 different versions of PyTorch 1.10. You do not want to get the GPU version. By far most installation failures happen at this step.

Right-click and download the .whl file to your local machine. Save it directly into the Wheels directory you just created, or download the file to your Downloads directory and then move it to the Wheels directory.


3. Launch a command shell. Note: depending on your system configuration, you may need to launch the shell with “Run as Administrator” admin privileges. Navigate to the directory where you saved the .whl file. Enter the command:

pip install “torch-1.10.0+cpu-cp37-cp37m-win_amd64.whl”

Installation of PyTorch is relatively quick. The shell will display a message indicating successful installation. To verify PyTorch has been installed correctly, enter the following three commands (note: there are two consecutive underscores in the version command).

python
import torch as T
T.__version__


If you succeeded, congratulations! You can only learn PyTorch by running and experimenting with programs; now you’re ready.



Note: To uninstall just PyTorch but nothing else, launch a command shell and enter “pip uninstall torch”. You’ll get asked for confirmation.

To uninstall everything (Python, PyTorch, Keras, TensorFlow), go to the Windows Control panel | Programs and Features | Uninstall and then uninstall Python-Anaconda. Make sure you know what you’re doing.

Note: Many PyTorch examples on the Internet work with image data, such as the MNIST hand-written digits dataset. To work with images you’ll eventually need the “torchvision” code library add-on. If you’re a beginner, I do not recommend installing torchvision. You can find a .whl file for torchvision on the same Web page as the PyTorch .whl file. For example:

torchvision-0.8.0%2Bcpu-cp37-cp37m-win_amd64.whl

You can right-click on the .whl file and download it to your local machine, and then install with a command such as:

pip install “torchvision-0.8.0%2Bcpu-cp37-cp37m-win_amd64.whl”

There is also a “torchtext” code library for natural language processing (NLP). NLP programs are significantly more complex than other types of problems so I definitely don’t recommend torchtext for beginners.


This entry was posted in Keras, PAW, PyTorch. Bookmark the permalink.

2 Responses to Installing PyTorch 1.10.0 on Windows 10/11

  1. Pingback: Installing Anaconda3 2020.02 with Python 3.7.6 on Windows 10/11 | James D. McCaffrey

  2. Pingback: Preparing a Machine for the 2022 Predictive Analytics World All-Day Workshop | James D. McCaffrey

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s