Secretflow is available in two editions: Lite and Full. The Lite edition is optimized for minimal size by excluding deep-learning related dependencies, making it more compact. On the other hand, the Full edition encompasses the complete set of dependencies for users requiring the full functionality of deep learning integration. Select the edition that best aligns with your specific requirements.
The simplest 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.
For Windows users, you could install SecretFlow base WSL2.
After installation, don't forget to have a quick try to check if SecretFlow is good to go.
Additional: For users with available GPU devices, you could try GPU support.
Python:3.10
pip: >= 19.3
OS: CentOS 7, Ubuntu 20.04
CPU/Memory: recommended minimum requirement is 8C16G.
Note: Due to CI resource limitation, macOS x64 prebuild binary is no longer available.
For users who want to try SecretFlow, you can install the current release.
Note that it requires python version == 3.10, you can create a virtual environment with conda if not satisfied.
conda create -n sf python=3.10
conda activate sf
After that, please use pip to install SecretFlow.
pip install -U secretflow
pip install -U secretflow-lite
You can also use SecretFlow Docker image to give SecretFlow a quick try.
docker run -it secretflow/secretflow-anolis8:latest
docker run -it secretflow/secretflow-lite-anolis8:latest
More versions can be obtained from secretflow tags.
git clone https://github.com/secretflow/secretflow.git
cd secretflow
conda create -n secretflow python=3.10
conda activate secretflow
python setup.py bdist_wheel
pip install dist/*.whl
python setup.py bdist_wheel --lite
pip install dist/*.whl
SecretFlow does not support Windows directly now, however, a Windows user can use secretFlow by WSL(Windows Subsystem for Linux).
Just follow the installation of anaconda in GNU/Linux to install anaconda in your WSL.
conda create -n sf python=3.10
conda activate sf
use pip to install SecretFlow.
pip install -U secretflow
pip install -U secretflow-lite
After set up of SecretFlow in WSL, you can use Pycharm Professional to Configure an interpreter using WSL or Visual Studio Code with WSL to use SecretFlow in Windows Operating System.
Try your first SecretFlow program.
Import secretflow package.
>>> import secretflow as sf
Create a local cluster with parties alice, bob and carol.
>>> sf.init(parties=['alice', 'bob', 'carol'], address='local')
Create alice's PYU device, which can process alice's data.
>>> alice_device = sf.PYU('alice')
Let alice say hello world.
>>> message_from_alice = alice_device(lambda x:x)("Hello World!")
Print the message.
>>> message_from_alice
<secretflow.device.device.pyu.PYUObject object at 0x7fdec24a15b0>
We see that the message on alice device is a PYU Object at deriver program.
Print the text at the driver by revealing the message.
>>> print(sf.reveal(message_from_alice))
Hello World!
If you don't need to use GPU, please ignore this section and refer to quick try.
NVIDIA's CUDA and cuDNN are typically used to accelerate the training and inference of machine learning models. Tensoflow and PyTorch, two widely-used machine learning frameworks, both intergrate the GPU support. In SecretFlow, PyTorch and Tensorflow are adopted as the backends for Federated Learning, of which the performance can be boosted with GPU support.
If you want to use GPU acceleration in SecretFlow, you need to complete the Preparations first to set up the environment.
In the following, there are two options to run the GPU-version SecretFlow:
After the image is ready, you could run the container and try GPU support.
Driver version must be >= 525.60.13 for CUDA 12 and >= 450.80.02 for CUDA 11 on Linux.
You could run NVIDIA System Management Interface (nvidia-smi) to make sure your NVIDIA driver is available and meet the version requirements.
nvidia-smi
NOTE: We currently only supply the GPU Docker image based on CUDA11. When the GPU packages of PyTorch and TensorFlow based on CUDA12 are available, we will supply the GPU Docker image based on CUDA12.
After the environment is set up, you could build/run the image.
The GPU Docker image of SecretFlow is available on the SecretFlow repository at Dockerhub and you can run the following command to get the latest GPU docker image.
docker pull secretflow/secretflow-gpu
For more information, please visit the GPU docker images at Dockerhub.
You could also build the Docker image by yourself.
git clone https://github.com/secretflow/secretflow.git
cd secretflow/docker
docker build -f secretflow-gpu.Dockerfile -t secretflow-gpu .
docker container run --runtime=nvidia -it --gpus all secretflow-gpu bash
NOTE: The following two parameters are necessary:
--runtime=nvidia
--gpus all
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。