{"id":13630009,"url":"https://github.com/Tencent/PhoenixGo","last_synced_at":"2025-04-17T13:31:08.969Z","repository":{"id":37406237,"uuid":"132723022","full_name":"Tencent/PhoenixGo","owner":"Tencent","description":"Go AI program which implements the AlphaGo Zero paper","archived":false,"fork":false,"pushed_at":"2019-03-11T11:19:25.000Z","size":225,"stargazers_count":2891,"open_issues_count":23,"forks_count":573,"subscribers_count":191,"default_branch":"master","last_synced_at":"2025-04-14T15:00:24.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-09T08:04:16.000Z","updated_at":"2025-04-10T11:45:55.000Z","dependencies_parsed_at":"2022-07-08T18:00:51.071Z","dependency_job_id":null,"html_url":"https://github.com/Tencent/PhoenixGo","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FPhoenixGo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FPhoenixGo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FPhoenixGo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FPhoenixGo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/PhoenixGo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249344762,"owners_count":21254729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:27.086Z","updated_at":"2025-04-17T13:31:08.941Z","avatar_url":"https://github.com/Tencent.png","language":"C++","readme":"![PhoenixGo](images/logo.jpg?raw=true)\n\n**PhoenixGo** is a Go AI program which implements the AlphaGo Zero paper\n\"[Mastering the game of Go without human knowledge](https://deepmind.com/documents/119/agz_unformatted_nature.pdf)\".\nIt is also known as \"BensonDarr\" and \"金毛测试\" in [FoxGo](http://weiqi.qq.com/), \n\"cronus\" in [CGOS](http://www.yss-aya.com/cgos/), and the champion of \n[World AI Go Tournament 2018](http://weiqi.qq.com/special/109) held in Fuzhou China.\n\nIf you use PhoenixGo in your project, please consider mentioning in your README.\n\nIf you use PhoenixGo in your research, please consider citing the library as follows:\n\n```\n@misc{PhoenixGo2018,\n  author = {Qinsong Zeng and Jianchang Zhang and Zhanpeng Zeng and Yongsheng Li and Ming Chen and Sifan Liu}\n  title = {PhoenixGo},\n  year = {2018},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/Tencent/PhoenixGo}}\n}\n```\n\n## Building and Running\n\n### On Linux\n\n#### Requirements\n\n* GCC with C++11 support\n* Bazel (**0.19.2 is known-good**)\n* (Optional) CUDA and cuDNN for GPU support \n* (Optional) TensorRT (for accelerating computation on GPU, 3.0.4 is known-good)\n\nThe following environments have also been tested by independent contributors : \n[here](/docs/tested-versions.md). Other versions may work, but they have not been \ntested (especially for bazel).\n\n#### Download and Install Bazel \n\nBefore starting, you need to download and install bazel,\nsee [here](https://docs.bazel.build/versions/master/install.html).\n\nFor PhoenixGo, bazel (**0.19.2 is known-good**), read \n[Requirements](#requirements) for details\n\nIf you have issues on how to install or start bazel, you may want \nto try this all-in-one command line for easier building instead, see\n[FAQ question](/docs/FAQ.md#b0-it-is-too-hard-to-install-bazel-or-start-bazel)\n\n#### Building PhoenixGo with Bazel\n\nClone the repository and configure the building:\n\n```\n$ git clone https://github.com/Tencent/PhoenixGo.git\n$ cd PhoenixGo\n$ ./configure\n```\n\n`./configure` will start the bazel configure : ask where CUDA \nand TensorRT have been installed, specify them if need.\n\nThen build with bazel:\n\n```\n$ bazel build //mcts:mcts_main\n```\n\nDependices such as Tensorflow will be downloaded automatically. \nThe building process may take a long time.\n\nRecommendation : the bazel building uses a lot of RAM, \nif your building environment is lack of RAM, you may need to restart \nyour computer and exit other running programs to free as much RAM \nas possible.\n\n#### Running PhoenixGo\n\nDownload and extract the trained network:\n\n```\n$ wget https://github.com/Tencent/PhoenixGo/releases/download/trained-network-20b-v1/trained-network-20b-v1.tar.gz\n$ tar xvzf trained-network-20b-v1.tar.gz\n```\n\nThe PhoenixGo engine supports GTP \n[(Go Text Protocol)](https://senseis.xmp.net/?GoTextProtocol),\nwhich means it can be used with a GUI with GTP capability, such as \n[Sabaki](http://sabaki.yichuanshen.de).\nIt can also run on command-line GTP server tools like \n[gtp2ogs](https://github.com/online-go/gtp2ogs).\n\nBut PhoenixGo does not support all GTP commands, see \n[FAQ question](/docs/FAQ.md/#a11-gtp-command-error--invalid-command).\n\nThere are 2 ways to run PhoenixGo engine\n\n##### 1) start.sh : easy use\n\nRun the engine : `scripts/start.sh`\n\n`start.sh` will automatically detect the number of GPUs, run `mcts_main` \nwith proper config file,\nand write log files in directory `log`.\n\nYou could also use a customized config file (.conf) by running \n`scripts/start.sh {config_path}`.\nIf you want to do that, see also [#configure-guide](#configure-guide).\n\n##### 2) mcts_main : fully control\n\nIf you want to fully control all the options of `mcts_main` (such \nas changing log destination, or if start.sh is not compatible for your \nspecific use), you can run directly `bazel-bin/mcts/mcts_main` instead.\n\nFor a typical usage, these command line options should be added:\n- `--gtp` to enable GTP mode\n- `--config_path=replace/with/path/to/your/config/file` to specify the \npath to your config file\n- it is also needed to edit your config file (.conf) and manually add \nthe full path to ckpt, see \n[FAQ question](/docs/FAQ.md/#a5-ckptzerockpt-20b-v1fp32plan-error-no-such-file-or-directory).\nYou can also change options in config file, see \n[#configure-guide](#configure-guide).\n- for other command line options , see also \n[#command-line-options](#command-line-options) \nfor details, or run `./mcts_main --help` . A copy of the `--help` is \nprovided for your convenience [here](/docs/mcts-main-help.md)\n\nFor example:\n\n```\n$ bazel-bin/mcts/mcts_main --gtp --config_path=etc/mcts_1gpu.conf --logtostderr --v=0\n```\n\n#### (Optional) : Distribute mode\n\nPhoenixGo support running with distributed workers, if there are GPUs \non different machine.\n\nBuild the distribute worker:\n\n```\n$ bazel build //dist:dist_zero_model_server\n```\n\nRun `dist_zero_model_server` on distributed worker, **one for each GPU**.\n\n```\n$ CUDA_VISIBLE_DEVICES={gpu} bazel-bin/dist/dist_zero_model_server --server_address=\"0.0.0.0:{port}\" --logtostderr\n```\n\nFill `ip:port` of workers in the config file (`etc/mcts_dist.conf` is an \nexample config for 32 workers), and run the distributed master:\n\n```\n$ scripts/start.sh etc/mcts_dist.conf\n```\n\n### On macOS\n\n**Note: Tensorflow stop providing GPU support on macOS since 1.2.0, so you are only able to run on CPU.**\n\n#### Use Pre-built Binary\n\nDownload and extract \n[CPU-only version (macOS)](https://github.com/Tencent/PhoenixGo/releases/download/mac-x64-cpuonly-v1/PhoenixGo-mac-x64-cpuonly-v1.tgz)\n\nFollow the document included in the archive : using_phoenixgo_on_mac.pdf\n\n#### Building from Source\n\nSame as Linux.\n\n### On Windows\n\nRecommendation: See [FAQ question](/docs/FAQ.md/#a4-syntax-error-windows), \nto avoid syntax errors in config file and command line options on Windows.\n\n#### Use Pre-built Binary\n\n##### GPU version :\n\nThe GPU version is much faster, but works only with compatible nvidia GPU.\nIt supports this environment : \n- CUDA 9.0 only\n- cudnn 7.1.x (x is any number) or lower for CUDA 9.0\n- no AVX, AVX2, AVX512 instructions supported in this release (so it is \ncurrently much slower than the linux version)\n- there is no TensorRT support on Windows\n\nDownload and extract \n[GPU version (Windows)](https://github.com/Tencent/PhoenixGo/releases/download/win-x64-gpu-v1/PhoenixGo-win-x64-gpu-v1.zip)\n\nThen follow the document included in the archive : how to install \nphoenixgo.pdf\n\nnote : to support special features like CUDA 10.0 or AVX512 for example, \nyou can build your own build for windows, see \n[#79](https://github.com/Tencent/PhoenixGo/issues/79)\n\n##### CPU-only version : \n\nIf your GPU is not compatible, or if you don't want to use a GPU, you can download this \n[CPU-only version (Windows)](https://github.com/Tencent/PhoenixGo/releases/download/win-x64-cpuonly-v1/PhoenixGo-win-x64-cpuonly-v1.zip), \n\nFollow the document included in the archive : how to install \nphoenixgo.pdf\n\n## Configure Guide\n\nHere are some important options in the config file:\n\n* `num_eval_threads`: should equal to the number of GPUs\n* `num_search_threads`: should a bit larger than `num_eval_threads * eval_batch_size`\n* `timeout_ms_per_step`: how many time will used for each move\n* `max_simulations_per_step`: how many simulations(also called playouts) will do for each move\n* `gpu_list`: use which GPUs, separated by comma\n* `model_config -\u003e train_dir`: directory where trained network stored\n* `model_config -\u003e checkpoint_path`: use which checkpoint, get from `train_dir/checkpoint` if not set\n* `model_config -\u003e enable_tensorrt`: use TensorRT or not\n* `model_config -\u003e tensorrt_model_path`: use which TensorRT model, if `enable_tensorrt`\n* `max_search_tree_size`: the maximum number of tree nodes, change it depends on memory size\n* `max_children_per_node`: the maximum children of each node, change it depends on memory size\n* `enable_background_search`: pondering in opponent's time\n* `early_stop`: genmove may return before `timeout_ms_per_step`, if the result would not change any more\n* `unstable_overtime`: think `timeout_ms_per_step * time_factor` more if the result still unstable\n* `behind_overtime`: think `timeout_ms_per_step * time_factor` more if winrate less than `act_threshold`\n\nOptions for distribute mode:\n\n* `enable_dist`: enable distribute mode\n* `dist_svr_addrs`: `ip:port` of distributed workers, multiple lines, one `ip:port` in each line\n* `dist_config -\u003e timeout_ms`: RPC timeout\n\nOptions for async distribute mode:\n\n\u003e Async mode is used when there are huge number of distributed workers (more than 200),\n\u003e which need too many eval threads and search threads in sync mode.\n\u003e `etc/mcts_async_dist.conf` is an example config for 256 workers.\n\n* `enable_async`: enable async mode\n* `enable_dist`: enable distribute mode\n* `dist_svr_addrs`: multiple lines, comma sperated lists of `ip:port` for each line\n* `num_eval_threads`: should equal to number of `dist_svr_addrs` lines\n* `eval_task_queue_size`: tunning depend on number of distribute workers\n* `num_search_threads`: tunning depend on number of distribute workers\n\nRead `mcts/mcts_config.proto` for more config options.\n\n## Command Line Options\n\n`mcts_main` accept options from command line:\n\n* `--config_path`: path of config file\n* `--gtp`: run as a GTP engine, if disable, gen next move only\n* `--init_moves`: initial moves on the go board, for example usage, see \n[FAQ question](/docs/FAQ.md/#a8-how-make-phoenixgo-start-at-other-position-at-move-1-and-after)\n* `--gpu_list`: override `gpu_list` in config file\n* `--listen_port`: work with `--gtp`, run gtp engine on port in TCP protocol\n* `--allow_ip`: work with `--listen_port`, list of client ip allowed to connect\n* `--fork_per_request`: work with `--listen_port`, fork for each request or not\n\nGlog options are also supported:\n\n* `--logtostderr`: log message to stderr\n* `--log_dir`: log to files in this directory\n* `--minloglevel`: log level, 0 - INFO, 1 - WARNING, 2 - ERROR\n* `--v`: verbose log, `--v=1` for turning on some debug log, `--v=0` to turning off\n\n`mcts_main --help` for more command line options.\nA copy of the `--help` is provided for your convenience \n[here](/docs/mcts-main-help.md)\n\n## Analysis\n\nFor analysis purpose, an easy way to display the PV (variations for \nmain move path) is `--logtostderr --v=1` which will display the main \nmove path winrate and continuation of moves analyzed, see \n[FAQ question](/docs/FAQ.md/#a2-where-is-the-pv-analysis-) for details\n\nIt is also possible to analyse .sgf files using analysis tools such as :\n- [GoReviewPartner](https://github.com/pnprog/goreviewpartner) : \nan automated tool to analyse and/or review one or many .sgf files \n(saved as .rsgf file). It supports PhoenixGo and other bots. See \n[FAQ question](/docs/FAQ.md/#a25-how-to-analyzereview-one-or-many-sgf-files-with-goreviewpartner) \nfor details\n\n## FAQ\n\nYou will find a lot of useful and important information, also most common \nproblems and errors and how to fix them\n\nPlease take time to read the [FAQ](/docs/FAQ.md)\n","funding_links":[],"categories":["C++","Projects List"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTencent%2FPhoenixGo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTencent%2FPhoenixGo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTencent%2FPhoenixGo/lists"}