机器之心编译
参与:李亚洲、路
本文介绍了腾讯微信翻译团队开源的人工智能围棋项目 PhoenixGo,该项目是对 DeepMind AlphaGo Zero 论文《Mastering the game of Go without human knowledge》的实现。
PhoenixGo 是腾讯微信翻译团队开发的人工智能围棋程序。据介绍,该项目由几名工程师在开发机器翻译引擎之余,基于 AlphaGo Zero 论文实现,做了若干提高训练效率的创新,并利用微信服务器的闲时计算资源进行自我对弈,缓解了 Zero 版本对海量资源的苛刻需求。
4 月底,在 2018 世界人工智能围棋大赛上,PhoenixGo 取得冠军。参赛队伍包括绝艺,LeelaZero、TSGo、石子旋风、Golois,HEROZ Kishi、Baduki 等来自中、日、韩、欧美等国家和地区的人工智能围棋高手。
5 月 11 日,PhoenixGo 在 Github 上正式开源,以下是技术细节:
项目地址:https://github.com/Tencent/PhoenixGo
如果你在研究中使用 PhoenixGo,请按以下方式引用库:
@misc{PhoenixGo2018,
author = {Qinsong Zeng and Jianchang Zhang and Zhanpeng Zeng and Yongsheng Li and Ming Chen and Sifan Liu}
title = {PhoenixGo},
year = {2018},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Tencent/PhoenixGo}}
}
构建和运行
在 Linux 上
1 要求
2 构建
复制库,并进行构建配置:
git clone https://github.com/Tencent/PhoenixGo.git
cd PhoenixGo
./configure
./configure 将询问 CUDA 和 TensorRT 的安装位置,如果必要指定二者的位置。
然后使用 bazel 进行构建:
bazel build //mcts:mcts_main
TensorFlow 等依赖项将会自动下载。构建过程可能需要很长时间。
3 运行
下载和提取训练好的网络:
wget https://github.com/Tencent/PhoenixGo/releases/download/trained-network-20b-v1/trained-network-20b-v1.tar.gz
tar xvzf trained-network-20b-v1.tar.gz
以 gtp 模式运行,使用配置文件(取决于 GPU 的数量和是否使用 TensorRT):
bazel-bin/mcts/mcts_main --config_path=etc/{config} --gtp --logtostderr --v=1
该引擎支持 GTP 协议,这意味着它可以和具备 GTP 能力的 GUI 一起使用,如 Sabaki。
--logtostderr 使 mcts_main 向 stderr 写入日志消息,如果你想将消息写入文件,将 --logtostderr 改成 --log_dir={log_dir} 即可。
你可以按照此说明更改配置文件:https://github.com/Tencent/PhoenixGo#configure-guide
4 分布模式
如果不同的机器上有 GPU,PhoenixGo 支持分布式 worker。
构建分布式 worker:
bazel build //dist:dist_zero_model_server
在分布式 worker 上运行 dist_zero_model_server,每个 worker 对应一个 GPU:
CUDA_VISIBLE_DEVICES={gpu} bazel-bin/dist/dist_zero_model_server --server_address="0.0.0.0:{port}" --logtostderr
在 config 文件中填充 worker 的 ip:port(etc/mcts_dist.conf 是 32 个 worker 的配置示例),并运行分布式 master:
bazel-bin/mcts/mcts_main --config_path=etc/{config} --gtp --logtostderr --v=1
在 macOS 上
注意:TensorFlow 在 1.2.0 版本之后停止支持 macOS 上的 GPU,因此在 macOS 上的操作只能在 CPU 上运行。
1 要求 & 构建
同 Linux。
2 运行
首先添加 libtensorflow_framework.so 到 LD_LIBRARY_PATH 中:
在 Windows 上
正在进行。
配置指南
以下是 config 文件中的一些重要选项:
分布模式的选项:
async 分布模式的选项:
Async 模式是在有大量分布式 worker 的时候使用的(多余 200),而在 sync 模式中需要过多的 eval 线程和搜索线程。
etc/mcts_async_dist.conf 是 256 个 worker 模式的 config 示例。
参看 mcts/mcts_config.proto 更详细的了解 config 选项。
命令行选项
mcts_main 接受以下命令行选项:
Glog 选项还支持:
mcts_main --help 支持更多命令行选项。