PyTorch - Python Deep Learning Neural Network API

Deep Learning Course - Level: Intermediate

PyTorch Install - Quick and Easy

video

expand_more chevron_left

text

expand_more chevron_left

Getting ready to install PyTorch

Welcome back to this series on neural network programming with PyTorch. In this episode, we are going to cover the needed prerequisites for installing PyTorch. Without further ado, let's get started.

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 (choose the latest Python version).
  2. Go to PyTorch's site and find the get started locally section.
  3. Specify the appropriate configuration options for your particular environment.
  4. Run the presented command in the terminal to install PyTorch.

For the example, suppose we have the following configuration:

Item Value
PyTorch Build Stable
OS Windows
Package Manager Conda
Language Python
Compute Platform CUDA 10.2

In this case, we have the following command:

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

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 torch
# packages in environment at C:\Users\deeplizard\Anaconda3:
#
# Name         Version    Build                    Channel
pytorch        1.10.2     py3.6_cuda10.2_cudnn7_0  pytorch
torchvision    0.11.3     py36_cu102               pytorch
torchaudio     0.10.2     py36_cu102               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
'10.2'

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.

logo-nvidia

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!

quiz

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Quiz Results

resources

expand_more chevron_left
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! πŸ•’πŸ¦Ž VIDEO SECTIONS πŸ¦ŽπŸ•’ 00:00 Welcome to DEEPLIZARD - Go to deeplizard.com for learning resources 00:30 Help deeplizard add video timestamps - See example in the description 07:32 Collective Intelligence and the DEEPLIZARD HIVEMIND πŸ’₯🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎πŸ’₯ πŸ‘‹ Hey, we're Chris and Mandy, the creators of deeplizard! πŸ‘€ CHECK OUT OUR VLOG: πŸ”— https://youtube.com/deeplizardvlog πŸ’ͺ CHECK OUT OUR FITNESS CHANNEL: πŸ”— https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA 🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order: πŸ”— https://neurohacker.com/shop?rfsn=6488344.d171c6 ❀️🦎 Special thanks to the following polymaths of the deeplizard hivemind: Mano Prime πŸ‘€ Follow deeplizard: Our vlog: https://youtube.com/deeplizardvlog Fitness: https://www.youtube.com/channel/UCdCxHNCexDrAx78VfAuyKiA Facebook: https://facebook.com/deeplizard Instagram: https://instagram.com/deeplizard Twitter: https://twitter.com/deeplizard Patreon: https://patreon.com/deeplizard YouTube: https://youtube.com/deeplizard πŸŽ“ Deep Learning with deeplizard: AI Art for Beginners - https://deeplizard.com/course/sdcpailzrd Deep Learning Dictionary - https://deeplizard.com/course/ddcpailzrd Deep Learning Fundamentals - https://deeplizard.com/course/dlcpailzrd Learn TensorFlow - https://deeplizard.com/course/tfcpailzrd Learn PyTorch - https://deeplizard.com/course/ptcpailzrd Natural Language Processing - https://deeplizard.com/course/txtcpailzrd Reinforcement Learning - https://deeplizard.com/course/rlcpailzrd Generative Adversarial Networks - https://deeplizard.com/course/gacpailzrd Stable Diffusion Masterclass - https://deeplizard.com/course/dicpailzrd πŸŽ“ Other Courses: DL Fundamentals Classic - https://deeplizard.com/learn/video/gZmobeGL0Yg Deep Learning Deployment - https://deeplizard.com/learn/video/SI1hVGvbbZ4 Data Science - https://deeplizard.com/learn/video/d11chG7Z-xk Trading - https://deeplizard.com/learn/video/ZpfCK_uHL9Y πŸ›’ Check out products deeplizard recommends on Amazon: πŸ”— https://amazon.com/shop/deeplizard πŸ“• Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard's link: πŸ”— https://amzn.to/2yoqWRn 🎡 deeplizard uses music by Kevin MacLeod πŸ”— https://youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ ❀️ Please use the knowledge gained from deeplizard content for good, not evil.

updates

expand_more chevron_left
deeplizard logo DEEPLIZARD Message notifications

Update history for this page

Did you know you that deeplizard content is regularly updated and maintained?

  • Updated
  • Maintained

Spot something that needs to be updated? Don't hesitate to let us know. We'll fix it!


All relevant updates for the content on this page are listed below.