PySyft is a Python library for secure and private Deep Learning. PySyft decouples private data from model training, using Federated Learning, Differential Privacy, and Multi-Party Computation (MPC) within the main Deep Learning frameworks like PyTorch and TensorFlow. Join the movement on Slack.
PySyft in Detail
A more detailed explanation of PySyft can be found in the white paper on arxiv
PySyft has also been explained in videos on YouTube:
Optionally, we recommend that you install PySyft within the Conda virtual environment, for its simplicity in installation. If you are using Windows, we suggest installing Anaconda and using the Anaconda Prompt to work from the command line.
conda create -n pysyft python=3 conda activate pysyft # some older version of conda require "source activate pysyft" instead. conda install jupyter notebook
Another alternative is to use python venvs. Those are our preferred environments for development purposes. We provide a direct install instructions in our makefile.
PySyft supports Python >= 3.6 and PyTorch 1.3
pip install syft[udacity]
This will auto-install the PyTorch and TF Encrypted dependencies, which are required for running the tutorials from Udacity's "Secure & Private AI" course (recommended).
You can install syft without these dependencies with the usual
pip install syft, but you will need to install framework
dependencies (i.e. PyTorch, TensorFlow, or TF Encrypted)
yourself. If you feel you've received an unexpected
installation error related to PyTorch or TF Encrypted, please
open an issue on Github or reach out to
If you have an installation error regarding zstd, run this command and then re-try installing syft.
pip install --upgrade --force-reinstall zstd
If this still doesn't work, and you happen to be on OSX, make sure you have OSX command line tools installed and try again.
If this still fails, and you are on a Conda environment. It could be because conda provides its own compiler and linker tools which might conflict with your system's. In that case we recommend to use a python venv and try again.
You can also install PySyft from source on a variety of operating systems by following this installation guide.
Run Local Notebook Server
All the examples can be played with by running the command
This assumes you want to use a local virtual environment. It installs it independently to the conda environment in case you installed one, or any other virtual environment you might have set up.
Once the jupyter notebook launches on your browser select the pysyft kernel.
Use the Docker image
Instead of installing all the dependencies on your computer, you can run a notebook server (which comes with Pysyft installed) using Docker. All you will have to do is start the container like this:
$ docker container run openmined/pysyft-notebook
You can use the provided link to access the jupyter notebook (the link is only accessible from your local machine).
NOTE: If you are using Docker Desktop for Mac, the port needs to be forwarded to localhost. In that case run docker with:
bash $ docker container run -p 8888:8888 openmined/pysyft-notebookto forward port 8888 from the container's interface to port 8888 on localhost and then access the notebook via http://127.0.0.1:8888/?token=...
You can also set the directory from which the server will serve notebooks (default is /workspace).
$ docker container run -e WORKSPACE_DIR=/root openmined/pysyft-notebook
You could also build the image on your own and run it locally:
$ cd docker-images/pysyft-notebook/ $ docker image build -t pysyft-notebook . $ docker container run pysyft-notebook
More information about how to use this image can be found on docker hub
Try out the Tutorials
A comprehensive list of tutorials can be found here
These tutorials cover how to perform techniques such as federated learning and differential privacy using PySyft.
The guide for contributors can be found here. It covers all that you need to know to start contributing code to PySyft in an easy way.
Also join the rapidly growing community of 5000+ on Slack. The slack community is very friendly and great about quickly answering questions about the use and development of PySyft!
We have written an installation example in this colab notebook, you can use it as is to start working with PySyft on the colab cloud, or use this setup to fix your installation locally.
We are very grateful for contributions to PySyft from the following organizations!
Do NOT use this code to protect data (private or otherwise) - at present it is very insecure. Come back in a couple months.