Skip to content

Instantly share code, notes, and snippets.

@dreiss
Created April 27, 2020 19:34
Show Gist options
  • Save dreiss/e0a261a9acc86afed59d22b63c9794ec to your computer and use it in GitHub Desktop.
Save dreiss/e0a261a9acc86afed59d22b63c9794ec to your computer and use it in GitHub Desktop.
# Get the aarch64 Minimal image from https://fedoraproject.org/wiki/Architectures/ARM/Raspberry_Pi#aarch64_supported_images_for_Raspberry_Pi_3
# Log in as root. Create new user. Log in as user.
sudo dnf update
sudo dnf install git cmake ninja-build clang unzip distcc python3-virtualenv python3-devel python3-opencv gstreamer1-plugins-base gstreamer1-plugins-good
sudo reboot
# Set up distcc symlinks for PATH.
mkdir ~/distcc-symlinks
mkdir ln -s `which distcc` ~/distcc-symlinks/clang
mkdir ln -s `which distcc` ~/distcc-symlinks/clang++
# NOTE: --system-site-packages is to get access to OpenCV from system package
python -m venv --system-site-packages venv-pytorch
. ~/venv-pytorch/bin/activate
# NOTE: Must install numpy *before* building pytorch
pip install pyyaml numpy
git clone https://github.com/pytorch/pytorch
cd pytorch
git submodule update --init --recursive
# Run this on server. Only the --daemon arg is *really* necessary.
distccd --verbose --log-stderr --daemon --no-detach --allow 127.0.0.1
# Establish tunnel between Pi and server. Run *one* of these commands.
ssh -R3632:localhost:3632 rasppi # Server-to-Pi
ssh -L3632:localhost:3632 server # Pi-to-Server
# Build PyTorch on the Pi
time env PATH="$HOME/distcc-symlinks:$PATH" DISTCC_VERBOSE=1 DISTCC_LOG=/tmp/distcc.log DISTCC_FALLBACK=0 DISTCC_BACKOFF_PERIOD=0 DISTCC_HOSTS='127.0.0.1' MAX_JOBS=8 CC=clang CXX=clang++ USE_DISTRIBUTED=0 BUILD_BINARY=1 BUILD_TEST=0 python setup.py develop
# DISTCC_VERBOSE and DISTCC_LOG are optional.
# DISTCC_BACKOFF_PERIOD is important because some commands are expected to fail during CMake setup.
# Make sure to use 127.0.0.1 and not "localhost".
# Can try making it 127.0.0.1,lzo to use compression.
# I experimented with MAX_JOBS and didn't find benefits over 4, but maybe I was doing something wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment