How to install PyTorch on Windows 10 using Anaconda

PyTorch Anaconda Windows 10

PyTorch Anaconda Windows 10

Updated Article Here:  Installing PyTorch 1.0 (Stable) with CUDA 10.0 on Windows 10 using Anaconda

I’m about halfway through the PyTorch Scholarship Challenge 2018-2019 hosted by Facebook/Udacity and so far it’s going really well! In my first IRL meetup with other students in the South Bay area, an interesting issue came up. Most of the students preferred installing and using PyTorch on Ubuntu (Linux) versus Windows 10. My guess is the installation was more difficult on Windows early on. I recently did not run into any issues so I thought I would put out a guide to help others who are still nervous about trying again or have not done it before. Hopefully it will save someone the effort and the cost of getting a separate development system running Ubuntu especially when most corporate workspaces are already using Windows 10. And if you’re a gamer, like me, and have a high end GeForce video card then your system can do double duty without having to dual boot into Linux or MacOS.

Step 1: Install NVIDIA CUDA 9.2

NVIDIA CUDA 9.2 Download Page
NVIDIA CUDA 9.2 Download Page

This is an optional step if you have a NVIDIA GeForce, Quadro or Tesla video card.  Download the NVIDIA CUDA Toolkit from the link below and install it.  Make sure you download version 9.2 and not version 10.  Although version 10 is the latest and greatest, it’s not currently supported by PyTorch at the time of this writing.

https://developer.nvidia.com/cuda-92-download-archive?target_os=Windows&target_arch=x86_64&target_version=10

Step 2: Install Anaconda with Python 3.7

Anaconda with Python 3.7
Anaconda with Python 3.7

Anaconda is a great development environment that is supported across MacOS, Windows and Linux. I highly recommend this program. It makes it easy to install several Python code editors and PyTorch.  My preferred editor is Spyder but Jupiter Notebook is also very popular and is used in a lot of the PyTorch challenge coursework. Download the file from the link below and install.

https://www.anaconda.com/download/#windows

Additionally here are some Windows installation instructions from Anaconda if you run into any trouble.

https://docs.anaconda.com/anaconda/install/windows/

Step 3: Install PyTorch from the Anaconda Terminal

Anaconda Prompt
Anaconda Prompt

Go to the Start Menu > Applications > Anaconda and open the Anaconda Prompt. Here you will run the following command to install PyTorch:

conda install pytorch cuda92 -c pytorch

If you didn’t install CUDA and plan to run your code on CPU only, use this command instead:

conda install pytorch-cpu -c pytorch

I also recommend installing Torchvision. It contains popular datasets, model architectures, and common image transformations for computer vision.

pip install torchvision

Lastly I recommend updating all the modules and dependancies in Anaconda using the following command:

conda update --all

Press “Y” to start the update. It will take a few minutes to finish.

Step 4: Choose your IDE

Anaconda Navigator
Anaconda Navigator

Now load Anaconda and choose either Spyder or Jupiter Notebook. You can also check for updates by clicking the gear icon in the upper right hand corner of the application. If you have any issues or find any problems, feel free to leave a comment and I’ll update the post. Thanks and happy programming!

2 thoughts on “How to install PyTorch on Windows 10 using Anaconda

    1. Hi Waqar!

      You don’t have to install CUDNN or the CUDA, it’s optional. Anaconda and PyTorch have everything you need to program in Python. CUDA is only useful if you want to run some commands or projects strictly from command line or using some examples provided by Nvidia.

Leave a Reply to Waqar Khan Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.