Facebook's Open Source AI Framework PyTorch is Looking Solid

Facebook already uses its own Open Source AI, PyTorch quite extensively in its own artificial intelligence projects. Recently, they have gone a league ahead by releasing a pre-release preview version 1.0.

For those who are not familiar, PyTorch is a Python-based library for Scientific Computing.

PyTorch harnesses the superior computational power of Graphical Processing Units (GPUs) for carrying out complex Tensor computations and implementing deep neural networks. So, it is used widely across the world by numerous researchers and developers.

This new ready-to-use Preview Release was announced at the PyTorch Developer Conference at The Midway, San Francisco, CA on Tuesday, October 2, 2018.

Highlights of PyTorch 1.0 Release Candidate

PyTorhc is Python based open source AI framework from Facebook

Some of the main new features in the release candidate are:

1. JIT

JIT is a set of compiler tools to bring research close to production. It includes a Python-based language called Torch Script and also ways to make existing code compatible with itself.

2. New torch.distributed library: “C10D”

β€œC10D” enables asynchronous operation on different backends with performance improvements on slower networks and more.

3. C++ frontend (experimental)

Though it has been specifically mentioned as an unstable API (expected in a pre-release), this is a pure C++ interface to the PyTorch backend that follows the API and architecture of the established Python frontend to enable research in high performance, low latency and C++ applications installed directly on hardware.

To know more, you can take a look at the complete update notes on GitHub.

The first stable version PyTorch 1.0 will be released in summer.

Installing PyTorch on Linux

To install PyTorch v1.0rc0, the developers recommend using Conda while there also other ways to do that as shown on their local installation page where they have documented everything necessary in detail.

Prerequisites

  • Linux
  • Pip
  • Python
  • CUDA (For Nvidia GPU owners)

As we recently showed you how to install and use Pip, let’s get to know how we can install PyTorch with it.

Note that PyTorch has GPU and CPU-only variants. You should install the one that suits your hardware.

Installing old and stable version of PyTorch

If you want the stable release (version 0.4) for your GPU, use:

pip install torch torchvision

Use these two commands in succession for a CPU-only stable release:

pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl
pip install torchvision

Installing PyTorch 1.0 Release Candidate

You install PyTorch 1.0 RC GPU version with this command:

pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html

If you do not have a GPU and would prefer a CPU-only version, use:

pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html

Verifying your PyTorch installation

Startup the python console on a terminal with the following simple command:

python

Now enter the following sample code line by line to verify your installation:

from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)

You should get an output like:

tensor([[0.3380, 0.3845, 0.3217],
        [0.8337, 0.9050, 0.2650],
        [0.2979, 0.7141, 0.9069],
        [0.1449, 0.1132, 0.1375],
        [0.4675, 0.3947, 0.1426]])

To check whether you can use PyTorch’s GPU capabilities, use the following sample code:

import torch
torch.cuda.is_available()

The resulting output should be:

True

Support for AMD GPUs for PyTorch is still under development, so complete test coverage is not yet provided as reported here, suggesting this resource in case you have an AMD GPU.

Lets now look into some research projects that extensively use PyTorch:

Ongoing Research Projects based on PyTorch

Nvidia, leading GPU manufacturer covered more on this with their own update on this recent development where you can also read about ongoing collaborative research endeavours.

How should we react to such PyTorch capabilities?

To think Facebook applies such amazingly innovative projects and more in its social media algorithms, should we appreciate all this or get alarmed? This is almost Skynet! This newly improved production-ready pre-release of PyTorch will certainly push things further ahead! Feel free to share your thoughts with us in the comments below!

About the author
Avimanyu Bandyopadhyay

Avimanyu Bandyopadhyay

Tech Nerd at It's FOSS | Doctoral Researcher on GPU-based Bioinformatics and author of <a href="https://www.packtpub.com/product/hands-on-gpu-computing-with-python/9781789341072">'Hands-On GPU Comput

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.