Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (77 sloc) 2.71 KB

Install PyTorch on Raspberry Pi

Platform:Raspberry Pi 3 B+
OS:Raspbian Stretch Lite
Torch:PyTorch 1.1.0
Python:Berryconda

This documentation serves as a memo for installing PyTorch (torch + caffe2) on Raspberry Pi. Unlike many online tutorials that start with the native python, I choose to compile it against the Miniconda python. Since the Miniconda is only available up to Python 3.5, Berryconda is used instead for Python 3.6.

Prerequisities

Berryconda

  1. Download Berryconda 3: https://github.com/jjhelmus/berryconda/releases/download/v2.0.0/Berryconda3-2.0.0-Linux-armv7l.sh

  2. Install via the sh script

    bash Berryconda3-2.0.0-Linux-armv7l.sh
    
  3. Make conda available in normal mode:

    echo ". ${HOME}/conda/etc/profile.d/conda.sh" >> ${HOME}/.bashrc
    
  4. Install Python dependencies:

    conda activate
    conda install cython m4 cmake pyyaml numpy
    conda deactivate
    

PyTorch

Now we can install PyTorch from source, which contains both torch and caffe2 packages.

  1. Clone the most current repository from GitHub:

    cd git
    git clone --recursive https://github.com/pytorch/pytorch
    cd pytorch
    git submodule update --init --recursive
    
  2. Disable component not available on Raspberry Pi by setting the build environment variables:

    export NO_CUDA=1
    export USE_FBGEMM=0
    export BUILD_TEST=0
    export USE_MIOPEN=0
    export USE_DISTRIBUTED=0
    export USE_MKLDNN=0
    export USE_NNPACK=0
    export USE_QNNPACK=0
    export BUILD_CAFFE2_OPS=0
    
  3. Build from source

    conda activate
    python setup.py build
    conda deactivate
    

Reference

This section shows the useful online tutorial/links I follow.

You can’t perform that action at this time.