• HawkEye 项目开发环境配置

    应邀安装一个科研项目开发环境,这份文档提供了安装步骤和运行建议。这个项目暴露的问题算是容易解决的一类。

    *

    原项目可在 Zenodo 获取。

    项目作者在 README 提供的脚本存在一些遗漏、过时且不够优雅的部分,想让项目运行起来参考这篇会更好。注意所有命令都在项目文件夹下运行。当然,这篇并不能完全取代 README。

    手动下载的脚本权限默认是关的,需要打开。

    chmod u+x Scripts/*.sh

    安装 Python 环境。

    apt update && apt upgrade
    apt install pipx
    pipx install uv
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
    uv venv --python 3.8
    source .venv/bin/activate
    uv pip install -r requirements.txt

    需要手动创建文件夹。

    mkdir -p Data/
    mkdir -p Programs/Profiling-data/

    运行 Python 脚本,具体含义请看项目作者提供的信息。

    ./Scripts/profiling-models-accuracy.sh
    
    ./Scripts/profiling-models-delphi.sh
    ./Scripts/profiling-models-cheetah.sh
    
    ./Scripts/profiling-models-semi2k.sh
    
    Scripts/profiling-models.sh
    python Scripts/profiling-models.py
    
    Scripts/profiling-sec-model.sh
    python Scripts/profiling-sec-model.py
    
    Scripts/profiling-opt.sh

    安装 C/C++ 环境。

    apt install automake build-essential cmake git libntl-dev libsodium-dev libssl-dev libtool m4 texinfo yasm

    其中在这台机器上这几个包已经安装了。

    build-essential is already the newest version (12.9ubuntu3).
    git is already the newest version (1:2.34.1-1ubuntu1.17).
    libssl-dev is already the newest version (3.0.2-0ubuntu1.23).
    cmake is already the newest version (3.22.1-1ubuntu1.22.04.2).

    这个项目应该使用了 git,但是相关文件不完整,请不要初始化 git 环境。这个命令会下载剩余的依赖源代码到 deps/ 中,并安装到 local/。如果用国内的服务器,没代理访问 github 也许会出问题。

    make -j$(nproc) boost && make -j$(nproc) libote && make -j$(nproc) mpir

    对于某些国内云服务器厂商,如 AutoDL 有额外支持。

    source /etc/network_turbo

    或者可以配置镜像类似于这种。

    git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/"

    恢复用完后原状。

    git config --global --unset-all url."https://gitclone.com/github.com/".insteadOf

    构建项目代码。

    make -j$(nproc) tldr
    make -j$(nproc) replicated-ring-party.x
    make -j$(nproc) Fake-Offline.x

    conda 的 c_rehash 在这个机器上有干扰。

    export PATH=/usr/bin:$PATH
    $ which c_rehash
    /usr/bin/c_rehash

    继续运行脚本。

    Scripts/setup-ssl.sh 3
    Scripts/setup-online.sh 3 64
    
    Scripts/resnet-opt.sh
    
    python Scripts/resnet_view.py

    下面的命令需要 tc。

    apt install iproute2

    去掉了文件 Scripts/resnet-opt.sh 中的所有 sudo。这个脚本使用了管理员权限。注意,运行期间会导致所有本地通信限速 9Mbps、延迟 36ms,使用时需小心。

    chmod +x resnet-opt.sh

    脚本开始加了 trap 'tc qdisc del dev lo root 2>/dev/null' EXIT 保证中断时,也能恢复原状。

    Scripts/resnet-opt.sh

    这个命令需要长期运行,建议安装 tmux。

    apt install tmux
    tmux new -s hawkeye
    Scripts/resnet-opt.sh

    至于最后这个脚本直接运行会有错误。应该是代码问题,在此不讨论。

    python Scripts/resnet_view.py