Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Install PyTorch on Raspberry Pi

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

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.



  1. Download Berryconda 3:

  2. Install via the sh script

  3. Make conda available in normal mode:

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

    conda activate
    conda install cython m4 cmake pyyaml numpy
    conda deactivate


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
    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 build
    conda deactivate


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