1.2.1 环境部署
这一节,我们从 环境解读、准备工作、小结 三个方面来学习。
环境解读
环境需求
Python:3.10 pip: >= 19.3 OS: CentOS 7, Ubuntu 20.04 CPU/Memory: 单机最小资源8C16G.
安装文件
Secretflow目前支持两种安装包: secretflow • 包含secretflow所有的requirements • 体积较大 secretflow-lite • 仅包含基础功能(不包含深度学习等依赖库) • 体积较小
安装方式
Secretflow支持三种安装方式 方式一:docker镜像 方式二:pypi 方式三:源码
docker镜像方式安装
二选一即可: docker run -it secretflow/secretflow-anolis8:latest docker run -it secretflow/secretflow-lite-anolis8:latest
pypi方式安装
pip upgrade pip install -U secretflow pip install -U secretflow-lite
源码方式安装
下载源码并建立Python虚拟环境 git clone https://github.com/secretflow/secretflow.git cd secretflow conda create -n secretflow python==3.8 conda activate secretflow
安装secretflow # 涉及到C++编译,建议使用镜像secretflow/release-ci:latest python setup.py bdist_wheel pip install dist/*.whl
准备工作
安装Docker环境
文件名:03_kubernetes_docker_install.sh #!/bin/bash # 功能: 安装部署Docker容器环境 # 版本: v0.1 # 作者: 王树森 # 联系: sswang.example.com # 准备工作 # 软件源配置 softs_base(){ # 安装基础软件 yum install -y yum-utils device-mapper-persistent-data lvm2 # 定制软件仓库源 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 更新软件源 systemctl restart network yum makecache fast } # 软件安装 soft_install(){ # 安装最新版的docker软件 yum install -y docker-ce # 重启docker服务 systemctl restart docker } # 加速器配置 speed_config(){ # 定制加速器配置 cat > /etc/docker/daemon.json <<-EOF { "registry-mirrors": [ "http://74f21445.m.daocloud.io", "https://registry.docker-cn.com", "http://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn" ], "insecure-registries": ["10.0.0.20:80"], "exec-opts": ["native.cgroupdriver=systemd"] } EOF # 重启docker服务 systemctl restart docker } # 环境监测 docker_check(){ process_name=$(docker info | grep 'p D' | awk '{print $NF}') [ "${process_name}" == "systemd" ] && echo "Docker软件部署完毕" || (echo "Docker软件部署失败" && exit) } # 软件部署 main(){ softs_base soft_install speed_config docker_check } # 调用主函数 main
执行脚本 /bin/bash 03_kubernetes_docker_install.sh 测试效果 ]# docker info Client: ... Server: ... Cgroup Driver: systemd ... Insecure Registries: 10.0.0.20:80 127.0.0.0/8 Registry Mirrors: http://74f21445.m.daocloud.io/ https://registry.docker-cn.com/ http://hub-mirror.c.163.com/ https://docker.mirrors.ustc.edu.cn/ Live Restore Enabled: false
docker方式部署环境
简单环境样式: [root@localhost ~]# docker run -it secretflow/secretflow-lite-anolis8 [root@7b4c1211a5a8 ~]#
标准环境样式: [root@localhost ~]# docker run -it secretflow/secretflow-anolis8 ... Welcome to use _____ __ ________ / ___/___ _____________ / /_/ ____/ /___ _ __ \__ \/ _ \/ ___/ ___/ _ \/ __/ /_ / / __ \ | /| / / ___/ / __/ /__/ / / __/ /_/ __/ / / /_/ / |/ |/ / /____/\___/\___/_/ \___/\__/_/ /_/\____/|__/|__/ Here are some information of this container The version of Python: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] The version of some packages SecretFlow: 1.5.0.dev20240321 SPU: 0.8.0b0 Ray: 2.9.1 Jax: 0.4.25 Jaxlib: 0.4.25 TensorFlow: 2.11.1 PyTorch: 2.1.2+cpu [root@c1f396680eae ~]#
小结