A Step by Step guide to installing PySyft in Raspberry Pi

Suparna S Nair
Secure and Private AI Writing Challenge
4 min readAug 17, 2019

Udacity Secure and Private AI Challenge

Welcome back, to the fourth article in this series on getting you prepped with training a recurrent neural network on Raspberry Pis.

In this article, I will take you through the steps to install PySyft, a secure and private deep learning open-source Python framework developed by the OpenMined community.

So, what’s Secure and Private AI?

There are tons of enlightening articles about secure AI and the privacy preserving techniques for AI (Curious readers can check here and here, to begin with!) and this article is not a primer for this topic. However, I would like to summarize the concept to get a clearer picture for the readers 😊.

With the enormous amount of data being used for training machine learning models across devices, privacy has become a concern of prime importance. Machine learning models and algorithms, however greatly relies on this data to perfect the models. So, there arises a need to balance this — the machine learning models and algorithm needs the data, but not with compromising the security and privacy of user’s data.

It is with this idea in mind that several researchers, scientists and technologists put their brains together to formulate new techniques to form a secure and private AI. This is achieved through different forms of encryption. Its an exciting field of research mainly due to its secure and private aspect.

In short — PySyft is a library for encrypted, privacy preserving AI.

PySyft was developed by the OpenMined community

Before we get started

The article assumes the following from the reader:

  • A Raspberry Pi with Raspbian Buster OS, with SSH enabled, and ability to access Pi via an SSH client like PuTTy from your laptop/PC
  • Ability for the RPi to access internet.
  • The PyTorch library installed in Raspberry Pi

PySyft library requires PyTorch and several other dependencies.

Most of the dependencies get resolved through pip installation, but PyTorch is a pre-requisite to install this. Hence, make sure that you have the latest version of PyTorch (torch≥1.1) installed. Later in this article, I will also detail the steps as to how to install PySyft for an older version of PyTorch (torch 1.0) as well.

Follow the steps as mentioned here to install PyTorch.

Installing PySyft in Raspberry Pi

Fortunately, Python PIP supports an official version of PySyft for ARM processor architecture (which is the architecture supported in Raspberry Pi) and hence we can use pip to install PySyft.

  • Launch terminal in your Raspberry Pi.
  • Type in the following:
pip3 install syft

If you are using PyTorch version 1.1 or above, then that’s it! Installation was a cake walk!

However …

… If you got the following error:

Could not find a version that satisfies the requirement torch>=1.1 syft

This means that you do not have PyTorch version 1.1+ installed in your Raspberry Pi. Probably you are having an older version and unfortunately the latest version of PySyft requires PyTorch V1.1 or above.

Do not lose hope! What do you generally do when you find that the latest version of a package does not support an older version of a pre-requisite package? You are right — DOWNGRADE PySyft! 😅

After several hours of trial and error and looking into the older versions of syft, I tried this (keeping my fingers crossed):

pip3 install syft==0.1.13a1

Alas, this too, gave me the same error. Later on I realized that the installation breaks while it tries to install other dependencies of syft, which further searches for torch v1.1+ or latest versions of some dependent libraries. This intuition, along with the excellent advice from two of my fellow scholarship challenge mates (I had mentioned earlier in the previous article that I am taking part in Udacity’s Secure and Private AI Scholarship Challenge 😁), I installed syft by explicitly mentioning to not install any of its dependencies (Sad that I cannot tag these amazing people here 🙁.) So, here’s the last try:

pip3 install syft==0.1.13a1 --no-dependencies

Hurray! This one worked like a charm.

More to the story

However, to ensure whether your package is correctly installed, one needs to import it in Python and it should execute without errors. I tried the same:

>>> import syft

And the console laughed at me with its scary red remarks:

Installed PySyft without dependencies and ended up this way 🙁

We obviously missed something here! Earlier we had installed PySyft without any dependencies, and we missed getting back to those dependencies later on!

So, let’s gear up for this one last bit of work:

sudo pip3 install Flask flask-socketio lz4 msgpack websockets zstd

Phew! 😅 That was a bunch of dependencies!

But your hardwork paid off! Try importing syft again:

>>> import syft>>>

Yaay! Time for a coffee! ☕🎉

If you go through the series of articles I crafted, you could see the obvious connection — we are trying to slowly unfold the steps to get you at training a recurrent neural network in a secure and private way in Raspberry Pi’s to give you the flavor of a real-world example. 😃 Be proud! And stay curious! 👏

--

--

Suparna S Nair
Secure and Private AI Writing Challenge

An artist and tinkerer by passion, a software engineer by profession!