Introduction

This article shows how you can install PyTorch on ARM64. PyTorch is a Python package that provides two high-level features:

PyTorch is an upcoming competitor to Google's TensorFlow and gains much popularity at the moment, as e.g. Theano is dead. The installation of PyTorch is not complicated. Just a few dependencies needs to be installed. In this article, a installation is done under Arch Linux. As hardware, I use my PINE A64.

Dependencies

Please make sure that the following dependencies are installed and up to date:

Compilation

After all dependencies have been installed on the host system, it is time to clone the latest PyTorch repository from GitHub. PyTorch also has some dependencies - controlled with Git submodules - which will be cloned, too:

    git clone --recursive https://github.com/pytorch/pytorch
  

As the PINE 64 does not have any NVIDIA supported GPU, we need to turn off the CUDA support. Therefore the following environment variable must be set:

    export NO_CUDA=1
  

In the next step we can compile and build PyTorch for the current user. Here we use a non system-wide installation, so it can be done with a non-priviliged user:

    python3 setup.py install --user
  

We use Python in version 3, as Python 2 is slowly dying now. The compilation will take about 75 minutes.

Useful hints

For the compilation, step I manually created a 4G swap partition. The PINE A64 has 2GB of RAM which is not sufficient for compiling PyTorch!

I found a bug when compiling PyTorch with recent GCC versions (GCC >= 6). The PyTorch team immediately fixed it so it is now possible to use it. Please make sure that you use a recent clone of the GitHub repository.

Testing the installation

Make sure that you leave the source directory of PyTorch to test if the installation was successful:

    $ python
    Python 3.6.3 (default, Oct 30 2017, 08:15:46)
    [GCC 7.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import torch
    >>> torch.__version__
    '0.4.0a0+5215640'
  

Summary

This article gives a short summary of compiling and installing PyTorch on ARM64. As there's currently no official package available via pip this is the recommended way to install PyTorch for minimal computing. In the next articles, I will show how you can use pretrained models on minimal computing hardware like a PINE A64.

History