由于历史原因,服务器是Centos8操作系统,所以源码编译异常的麻烦。特此记录如下。
采用源码编译方式可以在一步步的运行过程中对整个流程进行深刻的理解。
注意Centos8和Centos7有许多区别,部分库在centos8上不支持,所以安装过程与官方文档有不同地方。
需要 python3.8,假设python3.8已经安装成功,执行下面的安装。
sudo dnf -y install epel-release
sudo dnf -y group install "Development Tools"
sudo dnf -y install python38-devel gmp-devel libtool ninja-build git npm gcc make
sudo dnf -y --enablerepo=PowerTools install ninja-build
// 查看libstdc++.so.6链接的版本,如果是默认的6.0.19则需要升级版本
ls -l /usr/lib64/libstdc++.so.6
wget https://primihub.oss-cn-beijing.aliyuncs.com/tools/libstdc.so_.6.0.26.zip
unzip libstdc.so_.6.0.26.zip
sudo mv libstdc++.so.6.0.26 /usr/lib64
sudo rm -f /usr/lib64/libstdc++.so.6
sudo ln -s /usr/lib64/libstdc++.so.6.0.26 /usr/lib64/libstdc++.so.6
// Bazel 环境
sudo dnf config-manager --add-repo https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-8/vbatts-bazel-epel-8.repo
sudo dnf -y install bazel5
cd "/usr/bin" && sudo curl -fLO https://releases.bazel.build/5.0.0/release/bazel-5.0.0-linux-x86_64 && sudo chmod +x bazel-5.0.0-linux-x86_64
bazel --version
sudo dnf install redis -y
然后修改 /etc/redis/redis.conf
文件中的 requirepass
字段设置 redis 密码,该密码需要和 ./config/node*.yaml
文件 redis_password
字段的设置相同。
sudo sed -i 's/# requirepass foobared/requirepass primihub/' /etc/redis.conf
// 替换默认端口
sudo sed -i 's/port 6379/port 8391/' /etc/redis.conf
启动redis
sudo systemctl start redis
cd primihub
./pre_build.sh
make linux_x86_64
WORKSPACE_CN
找不到解决方法是直接将WORKSPACE_CN
中的内容贴到WORKSPACE
中。
解决方法:
WORKSPACE
中的github.com
替换为镜像地址,比如替换为 gitclone.com/github.com
。该方法由于地址不断再更新,测试后使用。方法2设置完之后,记得清理bazel的临时文件:
bazel clean --expunge
make linux_x86_64
。/home/baas/.cache/bazel/_bazel_baas/c4c8cad6a1643b7f6bba3835e75e462e/external/rules_java/temp2465207077681073091/
:ERROR: /home/baas/codes/mpc/primihub/BUILD.bazel:69:10: While resolving toolchains for target //:py_main: invalid registered toolchain '@local_jdk//:runtime_toolchain_definition': no such package '@rules_java//java': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz] to /home/baas/.cache/bazel/_bazel_baas/c4c8cad6a1643b7f6bba3835e75e462e/external/rules_java/temp2465207077681073091/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz: connect timed out
/home/baas/.cache/bazel/_bazel_baas/c4c8cad6a1643b7f6bba3835e75e462e/external
拷贝到该机器上。具体问题:
ERROR: /home/baas/codes/mpc/primihub/src/primihub/pybind_warpper/BUILD:23:17: Linking src/primihub/pybind_warpper/opt_paillier_c2py.so failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc @bazel-out/k8-fastbuild/bin/src/primihub/pybind_warpper/opt_paillier_c2py.so-2.params
问题原因:
之前使用python3.7
编译过一次,结果导致BUILD.bazel
文件中LACEHOLDER-PYTHON3.X-CONFIG
被替换为了python3.7
的参数。
替换脚本参考pre_build.sh
的 47 行:sed -e "s|PLACEHOLDER-PYTHON3.X-CONFIG|${NEWLINE}|g" BUILD.bazel > BUILD.bazel.tmp && mv BUILD.bazel.tmp BUILD.bazel
解决方法:
BUILD.bazel
BUILD.bazel
文件中 LINK_PYTHON_OPTS = xxxxxx
替换为原始的LINK_PYTHON_OPTS = PLACEHOLDER-PYTHON3.X-CONFIG
./pre_build.sh
requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC
具体问题列表:
/usr/bin/ld.gold: error: /usr/local/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(abstract.o): requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC
/usr/bin/ld.gold: error: /usr/local/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(boolobject.o): requires unsupported dynamic reloc 11; recompile with -fPIC
/usr/bin/ld.gold: error: /usr/local/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(bytearrayobject.o): requires dynamic R_X86_64_32 reloc against '_Py_NoneStruct' which may overflow at runtime; recompile with -fPIC
......
解决方法:使用-fPIC
重新编译Python3.8后安装
cd /opt/Python-3.8.16 // 我的安装路径
sudo ./configure --enable-optimizations CFLAGS="-fPIC"
sudo make clean
sudo make altinstall
编译完成之后,重新编译primihub:make linux_x86_64
查看start_server.sh
文件中,启动各个节点的配置文件在config
目录下:
- config
|-- node0.yaml
|-- node1.yaml
|-- node2.yaml
配置文件中datasets
字段设置了其对应的数据集,datasets 的字段定义如下:
description
:数据集的唯一可读性名称model
: 数据源类型,例子中是 csvsource
: 数据源在 Node 运行机器上的绝对路径node0.yaml
配置如下:
# load datasets
datasets:
# ABY3 LR test case datasets
- description: "train_party_0"
model: "csv"
source: "data/train_party_0.csv"
- description: "test_party_0"
model: "csv"
source: "data/test_party_0.csv"
- description: "breast_0"
model: "csv"
source: "data/FL/wisconsin.data"
# MNIST test case datasets
- description: "test_party_0_self"
model: "csv"
source: "data/falcon/dataset/MNIST/input_0"
- description: "test_party_0_next"
model: "csv"
source: "data/falcon/dataset/MNIST/input_1"
# FL homo lr test case datasets
- description: "homo_lr_data"
model: "csv"
source: "data/FL/homo_lr/breast_cancer.csv"
- description: "train_homo_lr"
model: "csv"
source: "data/FL/homo_lr/train_breast_cancer.csv"
# PSI test case datasets for sqlite database
- description: "psi_client_data_db"
model: "sqlite"
table_name: "psi_client_data"
source: "data/client_e.db3"
# Dataset authorization
# authorization:
# - node:
# task:
# PSI test caset datasets
- description: "psi_client_data"
model: "csv"
source: "data/client_e.csv"
# use mysql table as dataset
#- description: "psi_client"
# model: "mysql"
# host: "172.21.1.62"
# port: 3306
# username: "root"
# password: "primihub"
# database: "default"
# dbName: "psi"
# tableName: "psi_client"
# query_index: "ID" ## [[optional]]
其他配置信息修改见 config/node*.yaml
文件。
在代码根目录下执行如下命令:
sed -i /PYTHONPATH/d start_server.sh
bash start_server.sh
将启动三个服务节点,其相关日志分别保存在log_node0, log_node1, log_node2中
任务运行参考官方文档即可。
模板任务包括:
2023年6月5日 16点18分更新:
在CentoOS8下面配置之后,发现 FL 相关的示例都无法跑起来,所以现在转到Ubuntu20上测试下。