Neural Network Programming - Deep Learning with PyTorch

with deeplizard.

PyTorch Install - Quick and Easy

September 7, 2018 by

Blog

Getting ready to install PyTorch

Welcome back to this series on neural network programming with PyTorch. In this post, we are going to cover the needed prerequisites for installing PyTorch. Installing PyTorch is pretty easy, so without further ado, let's get it done.

pytorch logo

Installing PyTorch with Anaconda and Conda

Getting started with PyTorch is very easy. The recommended best option is to use the Anaconda Python package manager.

With Anaconda, it's easy to get and manage Python, Jupyter Notebook, and other commonly used packages for scientific computing and data science, like PyTorch!

Let’s go over the steps:

  1. Download and install Anaconda (Go with the latest Python version).
  2. Go to the Getting Started section on the PyTorch website.
  3. Specify the appropriate configuration options for your particular environment. For example:
    • OS: Windows
    • Package Manager: conda
    • Python: 3.6
    • CUDA: 9.0
  4. Run the presented command in the terminal to install PyTorch.

For the example configuration we specified in step (3), we have the following command:

> conda install PyTorch -c PyTorch 
> pip3 install torchvision
        

Notice that we are installing both PyTorch and torchvision. Also, there is no need to install CUDA separately. The needed CUDA software comes installed with PyTorch if a CUDA version is selected in step (3). All we need to do is select a version of CUDA if we have a supported Nvidia GPU on our system.

> conda list pytorch
# packages in environment at C:\Users\deeplizard\Anaconda3:
#
# Name    Version Build  Channel
pytorch   0.4.1   py36_cuda90_cudnn7he774522_1    pytorch

Jupyter Notebook and VS Code (optional)

In this series, we’ll be using the following software for writing, debugging our code:

Once you have Visual Studio Code installed, you’ll also want to install the Python plugin. This is done from inside VS Code, in the plugins section.

We'll be using VS Code primarily for debugging our code. VS code makes debugging our code and inspecting our objects pretty easy. It's also useful for exploring the PyTorch source code. The navigation features for source code are pretty robust.

We won't use VS code until part two of the series, and most of our time will be spent inside Jupyter notebook. We automatically get Jupyter Notebook with the Anaconda installation. Neither of these tools are necessary, but they do make our lives as developers a lot easier.

Verify the PyTorch install

To verify our PyTorch installation is all set and that we are ready to code, we'll do this in a notebook. To organize the various parts of our project, we will create a folder called PyTorch and put everything in this folder.

Steps to verify the install:

  1. To use PyTorch we import torch.
  2. To check the version, we use torch.__version__

Now, to verify our GPU capabilities, we use torch.cuda.is_available() and check the cuda version.

> torch.cuda.is_available()
True

> torch.version.cuda
'9.0'

If your torch.cuda.is_available() call returns false, it may be because you don’t have a supported Nvidia GPU installed on your system. However, don’t worry, a GPU is not required to use PyTorch or to follow this series.

nvidia logo

We can obtain quite good results in a reasonable amount of time even without having a GPU. If you’re interested in checking whether your Nvidia GPU supports CUDA, you can check for it here.

Wrapping up

In the next post, we’ll learn more about CUDA, GPUs, and importantly, why we even use GPUs in deep learning in the first place.

Let me know if you are all set, and I’ll see you in the next one!

Description

Getting started with PyTorch is very easy. The recommended best option is to use the Anaconda Python package manager. With Anaconda, it's easy to get and manage Python, Jupyter Notebook, and other commonly used packages for scientific computing and data science, like PyTorch! Let's do it! Check out the corresponding blog and other resources for this video at: http://deeplizard.com/learn/video/UWlFM0R_x6I Code: https://www.patreon.com/posts/code-for-pytorch-21607032 ❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Ruicong Xie Najib Akram Support collective intelligence, and join the deeplizard hivemind: http://deeplizard.com/hivemind Follow deeplizard: YouTube: https://www.youtube.com/deeplizard Twitter: https://twitter.com/deeplizard Facebook: https://www.facebook.com/Deeplizard-145413762948316 Steemit: https://steemit.com/@deeplizard Instagram: https://www.instagram.com/deeplizard/ Pinterest: https://www.pinterest.com/deeplizard/ Check out products deeplizard suggests on Amazon: https://www.amazon.com/shop/deeplizard Support deeplizard with crypto: Bitcoin: 1AFgm3fLTiG5pNPgnfkKdsktgxLCMYpxCN Litecoin: LTZ2AUGpDmFm85y89PFFvVR5QmfX6Rfzg3 Ether: 0x9105cd0ecbc921ad19f6d5f9dd249735da8269ef Recommended books on AI: The Most Human Human: What Artificial Intelligence Teaches Us About Being Alive: http://amzn.to/2GtjKqu Life 3.0: Being Human in the Age of Artificial Intelligence https://amzn.to/2H5Iau4 Playlists: Data Science - https://www.youtube.com/playlist?list=PLZbbT5o_s2xrth-Cqs_R9-us6IWk9x27z Machine Learning - https://www.youtube.com/playlist?list=PLZbbT5o_s2xq7LwI2y8_QtvuXZedL6tQU Keras - https://www.youtube.com/playlist?list=PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL TensorFlow.js - https://www.youtube.com/playlist?list=PLZbbT5o_s2xr83l8w44N_g3pygvajLrJ- PyTorch - https://www.youtube.com/watch?v=v5cngxo4mIg&list=PLZbbT5o_s2xrfNyHZsM6ufI0iZENK9xgG Music: Thinking Music by Kevin MacLeod Jarvic 8 by Kevin MacLeod YouTube: https://www.youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ Website: http://incompetech.com/ Licensed under Creative Commons: By Attribution 3.0 License http://creativecommons.org/licenses/by/3.0/