Installation#

The simplist way to try SecretFlow is to use offical docker image which shipps with SecretFlow binary.

Or you could install SecretFlow via Python Package Index.

For advanced users, you could install SecretFlow from source.

After installation, don’t forget to have a quick try to check if SecretFlow is good to go.

Environment#

Python:3.8

pip: >= 19.3

OS: CentOS 7, Ubuntu 18.04

CPU/Memory: recommended minimum requirement is 8C16G.

Option 1: from pypi#

For users who want to try SecretFlow, you can install the current release from pypi. Note that it requires python version == 3.8, you can create a virtual environment with conda if not satisfied.

conda create -n sf python=3.8
conda activate sf

After that, please use pip to install SecretFlow.

pip install -U secretflow

Option 2: from docker#

You can also use SecretFlow Docker image to give SecretFlow a quick try.

The latest version can be obtained from secretflow tags.

export version={SecretFlow version}

for example

export version=0.7.11b0

then run the image.

docker run -it secretflow/secretflow-anolis8:${version}

Option 3: from source#

  1. Download code and set up Python virtual environment.

git clone https://github.com/secretflow/secretflow.git
cd secretflow

conda create -n secretflow python=3.8
conda activate secretflow
  1. Install SecretFlow

python setup.py bdist_wheel

pip install dist/*.whl

A quick try#

Try your first SecretFlow program.

>>> import secretflow as sf
>>> sf.init(['alice', 'bob', 'carol'], num_cpus=8, log_to_driver=True)
>>> dev = sf.PYU('alice')
>>> import numpy as np
>>> data = dev(np.random.rand)(3, 4)
>>> data
<secretflow.device.device.pyu.PYUObject object at 0x7fdec24a15b0>