Note: These instructions work for PyTorch versions 1.6, 1.7, 1.8, 1.9, 1.10 too.
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.
Update on Sept. 10, 2020: PyTorch version 1.6 and TorchVision 0.7 have been released. These instructions work for these new versions too (I did not change my Anaconda / Python version).
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:
https://download.pytorch.org/whl/cpu/torch_stable.html
and
https://download.pytorch.org/whl/torch_stable.html
When you find the page, look for file:
torch-1.5.0%2Bcpu-cp37-cp37m-win_amd64.whl (or equivalent for version 1.6, 1.7, 1.8)
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).
python
import torch as T
T.__version__
Note: The screenshots below show the whl file download and installation for PyTorch 1.10.
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:
torchvision-0.6.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 the command:
pip install “torchvision-0.6.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 don’t recommend torchtext for beginners.
Pingback: Autoencoder Anomaly Detection Using PyTorch -- Visual Studio Magazine
Pingback: Positive and Unlabeled Learning (PUL) Using PyTorch –… – Machine Learning
Pingback: Sentiment Analysis Using a PyTorch EmbeddingBag Layer -- Visual Studio Magazine
Pingback: Computing the Similarity Between Two Machine Learning… – Machine Learning
Pingback: Calculating the similarity between two machine learning datasets - visual studio magazine - Roxxcloud
Pingback: Computing the Similarity Between Two Machine Learning Datasets - Visual Studio Magazine - ID Hub For Technology
Pingback: How to Fine-Tune a Transformer Architecture NLP Model – Visual Studio Magazine – xxp5 grooves
Pingback: How to Fine-Tune a Transformer Architecture NLP Model -- Visual Studio Magazine
Pingback: How To Compute Transformer Architecture Model Accuracy - Visual Studio Magazine - Vishwadha News
Pingback: How To Compute Transformer Architecture Model Accuracy — Visual Studio Magazine – Open Source Biology & Genetics Interest Group
Pingback: How To Compute Transformer Architecture Model Accuracy – Visual Studio Magazine – Auto Robot Demo
Pingback: How To Compute Transformer Architecture Model Accuracy – Visual Studio Magazine – xxp5 grooves
Pingback: Convolutional Neural Networks for MNIST Data Using PyTorch - Visual Studio Magazine - Scapi Services
Pingback: CIFAR-10 Image Classification Using PyTorch - Visual Studio Magazine - Scapi Services