PyTorch is a deep neural code library that you can access using the Python programming language. Anaconda is a collection of software packages that contains a base Python engine plus over 500 compatible Python packages.
Prerequisites: A machine with a relatively modern CPU (no older than 8 years old). You must be logged on as a user with full administrative privileges and be connected to the Internet.
1. Open the Windows Control Panel and delete all Python instances. You may have several different versions of Python installed. Note: In theory you can use PyTorch with multiple versions of Python on your machine, but you need to have expert skill to prevent software collisions and incompatibilities.
2. At this point you have no Python and no Python packages on your machine.
3. Do an Internet search for “anaconda archive” to find old versions of Anaconda. The URL when I wrote this post was https://repo.anaconda.com/archive/ but it could change. Locate the installer file for Windows, 64-bit, Anaconda version 2020.02 — be careful, it’s very easy to get the wrong file. It’s Anaconda3-2020.02-Windows-x86_64.exe. Double-click on it to execute directly, or right-click and download it to your local machine to any convenient directory. Then, after downloading, double-click on the executable installer to start installation.
4. You will see a Welcome screen. Double-check you have the correct version. Click “Next”.
5. You will see a License Agreement. Click “I Agree”.
6. You will see Installation Type. Accept the default “Just Me”.
7. You will see Installation Location. Accept the default. This will vary depending on whether you are logged on as a network user or a local user. The location is usually C:\Users\(user)\AppData\Local\Continuum\anaconda3 or C:\Users\(user)\Anaconda3. You should write this location down because everything goes here.
8. On the next screen you should check the box labelled “Add Anaconda to my PATH environment variable” in spite of the red warning message. Then click the “Install” button.
9. The installer will unzip thousands of files and then install them. The process takes 5-20 minutes. If you want, you can click on the “Details” button or you can just watch the green progress bar.
10. Eventually you will see an Installation Complete screen. Click “Next”.
11. You will see a screen that presents some marketing information. Click the “Next” button.
12. You will see a screen that has two check-boxes for more information. Uncheck both options and click the “Finish” button.
13. Python should now be installed. To test, open a command shell. Navigate to your root directory by typing “cd \” and hitting (Enter). Next type “python” (without the quotes). You should see the Python version 3.7.6 and the double-greater-than interactive prompt. Type “exit()” and hit (Enter).
14. Now you must find the .whl installation file for PyTorch 1.5 CPU on Python 3.7 for Windows. There are two main places where you might find it: pypi.org and pytorch.org.
Do an Internet search for “pytorch 1.5 cpu windows”. You may need to search a bit. I eventually found the .whl file at:
When you find the page, look for file:
Right-click and download the .whl file to your local machine. I suggest creating a C:\PyTorch\Wheels directory and saving there.
15. Launch a command shell and navigate to the directory where you saved the .whl file. Enter the command:
pip install “torch-1.5.0%2Bcpu-cp37-cp37m-win_amd64.whl”
Installation of PyTorch is relatively quick. The shell will display a message indicating successful installation. To verify PyTorch, enter the following commands (note: there are two consecutive underscores in the version command).
import torch as T
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, 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 need the “torchvision” code library add-on. You’ll likely find a .whl file for torchvision version 0.6 on the same Web page as the PyTorch .whl file. It’s named:
You can right-click on the .whl file and download it to your local machine, and then install with the command:
pip install “torchvision-0.6.0%2Bcpu-cp37-cp37m-win_amd64.whl”