Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Name Last commit Last update
..
roles
README.md
local.yml

Raspberry Pi Setup

This ansible Playbook does the following things:

  • Install pip3
  • Install jupyter-lab (version 3.2.4)
  • Setup a systemd service for jupyter-lab, enable it (autostart) and start it
  • Jupyter-lab is served on 0.0.0.0:8888 with an empty password. This of course has security implications and should be discussed
  • Install the following python3 packages:
    • numpy (version 1.21)
    • scikit-learn, aka. sklearn (version 1.0)
    • matplotlib (version 3.4)
    • pandas (version 1.3)
    • Pillow (version 8.4)
    • seaborn (version 0.11)
    • plotly (version 5.4)
    • nltk (version 3.6)
    • tensorflow (version 2.7.0)
  • All python packages are installed into a virtual environment at ~/.ml-venv. This also includes jupyter-lab which allows for using the default python3 kernel and still having access to all dependencies

The project is structured as follows:

Using the ansible playbook on Raspberry Pi OS

Steps to run the ansible script on a fresh (or not fresh) installation of raspberry pi os:

# Update the APT repo sources
sudo apt update
# Install ansible and git. git is already present on the desktop os version
sudo apt install -y --no-install-recommends ansible git

# Pull and run the ansible scripts from git
ansible-pull -U https://code.fbi.h-da.de/pse-ai-at-the-edge/raspberry-pi-setup.git

Notes

Changing optional settings

There are a bunch of optional settings in the script with default values that can be changed if needed. When running the script on a normal Pi with the default user, there is no need to change any of those.

The configurable options are the following:

Variable name Default value Description
target_user pi Setup for a specified user
jupyter_service true Setup a systemd service for running in the background
jupyter_start true Don't start jupyterlab directly
jupyter_autostart true Set the jupyterlab service to autostart
ignore_python_version false Ignore the python version check (not recommended)
ignore_architecture false Ignore the architecture check (not recommended)

To change any of these values add -e "[var1]=[value1] [var2]=[value2]" to the ansible-pull command.

Important: To set a value to false use -e [var]='' and not -e [var]=false. This is necessary due to ansible interpreting all extra-vars as strings.

Raspberry Pi OS Version and Architecture

This current version of the playbook will install a prebuilt tensorflow-2.7 wheel that only works on Python3.9 and the Aarch64 architecture. That means for now the playbook only works on Raspberry Pi OS 11 64-bit

Updating the playbook for 32-bit Raspberry Pi OS

Besides tensorflow all other dependencies will pretty much work regardless of architecture and python3 version. So to make this playbook work on 32-bit a decision must be made depending on the architecture. On 32-bit a different prebuilt tensorflow wheel must be used, as well as another numpy version. No prebuilt wheels were found yet for 32-bit in combination with python3.9 (debian / raspberry pi os 11), only for python3.7 which is not compatible with the current version of raspberry pi os.