首页 > 技术文章 > 关于Linux安装SEAL-python心得

zhengkaixin 2021-08-23 21:44 原文

github网站:https://github.com/Huelse/SEAL-Python
我是参考该github的README,在linux环境下安装SEAL-Python,期间遇到一些问题,我修改了一下原来的指令,以下是我的经验。

安装方法

原文档的步骤

Linux
Clang++ (>= 5.0) or GNU G++ (>= 6.0), CMake (>= 3.12)

# Optional
sudo apt-get install git build-essential cmake python3 python3-dev python3-pip

# Get the repository or download from the releases
git clone https://github.com/Huelse/SEAL-Python.git
cd SEAL-Python

# Numpy is essential
pip3 install -r requirements.txt

# Init the SEAL and pybind11
git submodule update --init --recursive
# Get the newest repositories (unnecessary)
# git submodule update --remote

# Build the SEAL lib
cd SEAL
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
cmake --build build
cd ..

# Run the setup.py
python3 setup.py build_ext -i

详细参照原github地址

问题与解决

1.git clone https://github.com/Huelse/SEAL-Python.git
我使用的是实验室的服务器,用的网络比较差,下载太慢,一开始clone失败,可以改为:
git clone git://github.com/Huelse/SEAL-Python.git

2.git submodule update --init --recursive
同样可能是由于网络问题,在更新子仓库的时候,报错
fatal: clone of 'https://github.com/pybind/pybind11.git' into submodule path '/xxx/xxx/SEAL-Python/pybind11' failed
我去issue向原作者提问,他的解答是:查看http://git-scm.com/docs/git-submodule or git submodule init && git submodule update

之后我用这个方法无法解决问题,我的解决思路还是修改url
git submodule update 更新的原理是根据.gitmodules文件中的url进行更新
可以在linux系统下使用vim进入编辑器模式,修改其中url地址
我的做法:

https://github.com/microsoft/SEAL.git改为 https://github.com.cnpmjs.org/microsoft/SEAL.git
https://github.com/pybind/pybind11.git改为 https://github.com.cnpmjs.org/pybind/pybind11.git

cd SEAL
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
cmake --build build

提示:
The source directory /xx/build does not exist

  • 首先看了cmake的文档

    文档上写着“构建根目录如果不存在将会自动创建”,但是我就没有自动创建
  • 建议新建build文件进行编译
mkdir build
cd build
cmake ../ build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF
  • 然后返回SEAL目录下
cd ..
cmake --build build

结语

可能是由于网络原因安装过程还挺麻烦的,我想把经验分享给遇到相同问题的朋友们。如果遇到问题是在找不到解决方案,主要要学会看文档把原理搞懂,然后摸索是哪部分出了问题。

参考

https://github.com/Huelse/SEAL-Python
https://www.jianshu.com/p/1e704e20eab8
https://blog.csdn.net/King_key/article/details/111595201

推荐阅读