The simplist way to try SecretFlow is to use offical docker image which ships 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.
Python:3.8
pip: >= 19.3
OS: CentOS 7, Ubuntu 18.04
CPU/Memory: recommended minimum requirement is 8C16G.
For users who want to try SecretFlow, you can install the current release.
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
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.6.13b1
then run the image.
docker run -it secretflow/secretflow-anolis8:${version}
- 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
- Install SecretFlow
python setup.py bdist_wheel
pip install dist/*.whl
SecretFlow does not support Windows directly now, however, a Windows user can use secretFlow by WSL(Windows Subsystem for Linux).
- Install WSL2 in Windows
- You are supposed to follow the guide_zh or guide_en to install WSL(Windows Subsystem for Linux) in your Windows and make sure that the version of WSL is 2.
- As for the distribution of GNU/Linux, Ubuntu is recommended.
- Install Anaconda in WSL
Just follow the installation of anaconda in GNU/Linux to install anaconda in your WSL.
- Install secretflow
- create conda environment
conda create -n sf python=3.8
- activate the environment
conda activate sf
- use pip to install SecretFlow.
pip install -U secretflow
NVIDIA's CUDA and cuDNN are typically used to accelerate the training and testing of Tensoflow and PyTorch deep learning models. Tensoflow and PyTorch are both deep learning backends for SecretFlow, and if you want to use GPU acceleration in SecretFlow, you can follow these steps:
- Make sure your NVIDIA driver is available
nvidia-smi
- Follow the NVIDIA official guide to setup NVIDIA Container Toolkit on your distributions.
- Use a dockerfile file to construct an image
- Download code
git clone https://github.com/secretflow/secretflow.git
cd secretflow/docker
- Construct an image
docker build -f sf-gpu.Dockerfile -t secretflow-gpu .
- Run an container
docker container run -it --gpus all secretflow-gpu bash
--gpus all
:This parameters and values are essential
- After the container is running, you can use the jupyter notebook ./docs/tutorial/GPU_check.ipynb to check the callability of Tensorflow and PyTorch for NVIDIA GPUs inside the container.
Try your first SecretFlow program.
>>> import secretflow as sf
>>> sf.init(['alice', 'bob', 'carol'], address='local')
>>> dev = sf.PYU('alice')
>>> import numpy as np
>>> data = dev(np.random.rand)(3, 4)
>>> data
<secretflow.device.device.pyu.PYUObject object at 0x7fdec24a15b0>