Installing PyTorch on Windows

PyTorch is an open source neural network code library developed by Facebook. PyTorch is similar to Google’s TensorFlow and Microsoft’s CNTK. PyTorch is gaining market share, primarily at the expense of my favorite library CNTK, so I decided I’d embark on the long journey to PyTorch expertise.

PyTorch is the least mature of the major neural network libraries and I discovered that even installing PyTorch on Windows was a challenge, mostly due to the terrible documentation — terrible in the sense that PyTorch is so new and changes so quickly, there’s lots of old and now incorrect information on the Internet. As best as I can determine, PyTorch on Windows has been officially supported only for 12 weeks as I write this blog post.

My base system is the Anaconda distribution with Python 3.5.2 — I should probably upgrade to a Python 3.6 version but that’ll have to wait for another day. The first step was to locate a .whl file for PyTorch for a Windows machine with no supported GPU. After a bit of Bing-ing and Googling around, I found a URL pointing to such a .whl file at

I pasted the URL of the .whl file into a browser address bar, and the browser gave me the opportunity to download the .whl file and so I did, saving it at C:\PyTorch\Wheels directory.

Next I opened a command shell and navigated to the location of the .whl file. Then I issued the command

> pip install torch-0.4.1-cp35-cp35m-win_amd64.whl

Notice that the latest version of PyTorch is only 0.4.1 — it’s still very early in the game.

After installing PyTorch, I installed the “torchvision” package which has many functions and dataset related to computer vision (such as the CIFAR image dataset). Instead of locating and saving a .whl file for torchvision, I installed directly:

> pip install torchvision

This was a bit risky because I’m letting PIP determine which version (0.2.1 — the current one) of torchvision to download.

Finally, I tested PyTorch by firing up the Python interpreter, importing pytorch and torchvision, and displaying their versions.

OK, installation completed. Next step . . . well, I’m not sure yet. Learning a new library like PyTorch takes a lot of time and effort — there are no shortcuts.

Tiki girl with tiki torch by artist Josh Agle

This entry was posted in Machine Learning, PyTorch. Bookmark the permalink.