standalone_fate_source_code_deployment_guide.zh.md 5.7 KB

源码部署FATE单机版

[TOC]

1. 说明

服务器配置:

数量 1
配置 8 core / 16G memory / 500G hard disk
操作系统 Version: CentOS Linux release 7
用户 User: app owner:apps

2. 部署前环境检查

本地8080、9360、9380端口是否被占用

netstat -apln|grep 8080
netstat -apln|grep 9360
netstat -apln|grep 9380

3. 获取源代码

请使用 git clone 本仓库及所有 submodules,然后设置部署所需环境变量

注意:通过以下方式设置的环境变量仅在当前终端会话有效, 若打开新的终端会话, 如重新登录或者新窗口, 请重新设置

cd {上述代码的存放目录}
export FATE_PROJECT_BASE=$PWD
export version=`grep "FATE=" ${FATE_PROJECT_BASE}/fate.env | awk -F "=" '{print $2}'`

4. 安装并配置Python环境

4.1 安装Python环境(可选)

请安装或者使用已有的 Python 3.8 版本

4.2 为FATE配置虚拟环境

cd(or create) {放置虚拟环境的根目录}
python3 -m venv {虚拟环境名称}
export FATE_VENV_BASE={放置虚拟环境的根目录}/{虚拟环境名称}
source ${FATE_VENV_BASE}/bin/activate

4.3 安装FATE所需要的Python依赖包

cd ${FATE_PROJECT_BASE}
bash bin/install_os_dependencies.sh
source ${FATE_VENV_BASE}/bin/activate
pip install -r python/requirements.txt

如果出现相关问题, 可以先参考可能遇到的问题

5. 配置FATE

编辑bin/init_env.sh环境变量文件

cd ${FATE_PROJECT_BASE}
sed -i.bak "s#PYTHONPATH=.*#PYTHONPATH=$PWD/python:$PWD/fateflow/python#g" bin/init_env.sh
sed -i.bak "s#venv=.*#venv=${FATE_VENV_BASE}#g" bin/init_env.sh

检查conf/service_conf.yaml全局配置文件中是否将基础引擎配置为单机版, 若default_engines显示如下,则为单机版

default_engines:
  computing: standalone
  federation: standalone
  storage: standalone

6. 启动fate flow server

cd ${FATE_PROJECT_BASE}
source bin/init_env.sh

cd fateflow
bash bin/service.sh status
bash bin/service.sh start

显示如下类似则为启动成功,否则请依据提示查看日志

service start sucessfully. pid: 111907
status:app      111907 75.7  1.1 3740008 373448 pts/2  Sl+  12:21   0:17 python /xx/FATE/fateflow/python/fate_flow/fate_flow_server.py
python  111907  app   14u  IPv4 3570158828      0t0  TCP localhost:boxp (LISTEN)
python  111907  app   13u  IPv4 3570158827      0t0  TCP localhost:9360 (LISTEN)

7. 安装fate client

cd ${FATE_PROJECT_BASE}
source bin/init_env.sh

cd python/fate_client/
python setup.py install

初始化fate flow client

cd ../../
flow init -c conf/service_conf.yaml

显示如下类似则为初始化成功,否则请依据提示查看日志

{
    "retcode": 0,
    "retmsg": "Fate Flow CLI has been initialized successfully."
}

8. 测试项

8.1 Toy测试

   flow test toy -gid 10000 -hid 10000

如果成功,屏幕显示类似下方的语句:

   success to calculate secure_sum, it is 2000.0

8.2 单元测试

   cd ${FATE_PROJECT_BASE}
   bash ./python/federatedml/test/run_test.sh

如果成功,屏幕显示类似下方的语句:

   there are 0 failed test

有些用例算法在 examples 文件夹下, 请尝试使用。 Please refer here for a quick start tutorial.

您还可以通过浏览器体验算法过程看板,请参照编译包安装fateboard

9. 编译fateboard(可选)

使用fateboard可视化FATE Job

9.1 配置Java环境

mkdir ${FATE_PROJECT_BASE}/env
cd ${FATE_PROJECT_BASE}/env

wget https://webank-ai-1251170195.cos.ap-guangzhou.myqcloud.com/resources/jdk-8u192.tar.gz
tar xzf jdk-8u192.tar.gz

wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar xzf apache-maven-3.8.6-bin.tar.gz

配置环境变量

export JAVA_HOME=${FATE_PROJECT_BASE}/env/jdk-8u192

cd ${FATE_PROJECT_BASE}
sed -i.bak "s#JAVA_HOME=.*#JAVA_HOME=${JAVA_HOME}#g" bin/init_env.sh

9.2 编译fateboard

cd ${FATE_PROJECT_BASE}/fateboard
${FATE_PROJECT_BASE}/env/apache-maven-3.8.6/bin/mvn -DskipTests clean package

9.3 启动fateboard

cd ${FATE_PROJECT_BASE}/fateboard
bash service.sh status
bash service.sh start

显示如下类似则为启动成功,否则请依据提示查看日志

JAVA_HOME=/data/project/deploy/FATE/env/jdk/jdk-8u192/
service start sucessfully. pid: 116985
status:
        app      116985  333  1.7 5087004 581460 pts/2  Sl+  14:11   0:06 /xx/FATE/env/jdk/jdk-8u192//bin/java -Dspring.config.location=/xx/FATE/fateboard/conf/application.properties -Dssh_config_file=/xx/FATE/fateboard/ssh/ -Xmx2048m -Xms2048m -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -jar /xx/FATE/fateboard/fateboard.jar

访问:http://${ip}:8080, ip为127.0.0.1或本机实际ip

10. 可能会遇到的问题

  • 如果出现"Too many open files"类似错误,可能是因为操作系统句柄数配置过低

    • 对于MacOS, 可以尝试这里
    • 对于Linux, 可以尝试这儿
  • 如果在MacOS下面, 安装gmpy2这个python依赖包失败的话, 尝试先安装如下基础库后, 再安装依赖包

brew install gmp mpfr libmpc