Skip to content

For Developers

He edited this page Apr 10, 2018 · 3 revisions

To help the project get stronger by running self-play training games on your own computer, see below for instructions. The project depends on users like you donating their CPU and GPU time to improve!

Download the code

Download the code from https://github.com/NeymarL/ChineseChess-AlphaZero, e.g.

  • git clone -b distributed https://github.com/NeymarL/ChineseChess-AlphaZero.git or
  • download zip

Environment Configuration

The project run in Python3.6.3+, if you don't have Python3.6.3+, see Anaconda.

Anaconda

If you already have Python3.6.3+ installed and it works well, just skip this section.

  1. Download and install anaconda (or miniconda) from https://conda.io/docs/user-guide/install/download.html
  2. Create a virtual environment for this project: conda create -n alphazero python=3.6 anaconda
  3. Activate the environment: source activate alphazero

Install Requirements

Note: If you just want to use CPU to train, replace tensorflow-gpu with tensorflow in requirements.txt.

Enter the root folder of the project and run

pip install -r requirements.txt

Running Self-Play

Tune the parameters

Before running self-play, there are some parameters that you can tune to fit you computer.

In file cchess_alphazero/configs/distribute.py:

  • line 35: self.max_processes = 10, this is the number of processes that run self-play worker, tune this to fit your number of CPU cores.
  • line 36: self.search_threads = 20, this is the number of search threads that each process use. Increase this parameter, playing will be faster but with weaker performance, you'd better tune this in range [10, 40].

Self-Play

Enter the root folder of the project and run:

python cchess_alphazero/run.py --type distribute --distributed self

If you want to specify which GPU to use, add --gpu [GPU] option. About more options please refer here.

Note: It takes about 1 or 2 minutes to start self-play since it need download the latest weight from server.

Stop Self-Play

If you want to stop self-play, just input Ctrl+C or close the terminal (console).

Run in Background (for Linux)

If you want to run in background, run:

nohup python cchess_alphazero/run.py --type distribute --distributed self >self-play.out 2>&1 &

The output will be redirected to self-play.out.

When you want to stop self-play, find process ids in the head of self-play.out and kill them each.

Live Status

For live status, see http://alphazero.52coding.com.cn/

Clone this wiki locally