Skip to content

[Linux] How to install Open Source Go Chess AI LeelaZero

Almost no one among Go chess enthusiasts does not know LeelaZero. It is the same as the famous 絕藝 in China, followed by the Go AI trained by AlphaGo Zero using reinforcement learning (RL).

LeelaZero is an open source project so we can check its source code on GitHub: https://github.com/leela-zero/leela-zero

Today I plan to record how to install LeelaZero on Linux operating system.

We need to check the following steps:

  • Your GPU can work (If you want to use cpu only, you can pass it)
  • Download LeelaZero
  • Download LeelaZero weights file
  • Download a GUI program to interact with LeelaZero

Check you GPU can work

If your GPU belongs to Nvidia you can go to https://www.nvidia.com/download/index.aspx?lang=en-us to download your driver.

The display card information can be viewed by the following command:

ubuntu-drivers devices

Maybe you can refer this article: [Linux] Install CUDA and CuDNN on Ubuntu 18.04


Download LeelaZero

First at all, we can follow the README.md on GitHub to install it step by step. First install OpenCL-a processor framework that can be hardware accelerated on various hardware devices.

sudo apt install clinfo && clinfo


git clone project:

git clone https://github.com/leela-zero/leela-zero
cd leela-zero
git submodule update --init --recursive


Install related packages:

sudo apt install cmake g++ libboost-dev libboost-program-options-dev libboost-filesystem-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev


cmake:

mkdir build && cd build
cmake ..
cmake --build .

Then, we should see the "leelaz" program under the leela-zero/build/ folder. At this point, the main body installation has come to an end.

However, the empty program body has no weight, and the neural network model still cannot work, so we then install the weight network.


Download LeelaZero Weights

If there is no special requirement when downloading LeelaZero weights, you can directly download the latest version.

wget http://zero.sjeng.org/best-network


However, in order for LeelaZero to actually use this weighted network, we need to copy this weighted network to the following path:

cp best-network ~/.local/share/leela-zero/

However, if you want to directly use a graphical interface such as Sabaki to open the game, then this step may be omitted, after all, the weight network path will be directly filled in afterwards.


Install GUI program

This note uses Sabaki as an example.

First, install npm first. npm is usually a package management tool installed with NodeJS. If you have not used it before, you need to install it before you can use the following installation instructions.

sudo apt install npm


Then git clone Sabaki's project and install:

git clone https://github.com/SabakiHQ/Sabaki.git
cd Sabaki
npm install
npm run build


After installation, there will be a "sabaki" program under Sabaki/dist/linux-unpacked/, use

./sabaki


Then open it.


Set up the LeelaZero engine

Of course, just installing Sabaki still failed to play chess. We need to set the path corresponding to the newly installed LeelaZero program on Sabaki.


Click Engines => Manage Engines… to enter the place of engine management:

  • (Unnamed Engine): You can set the name of the engine you want
  • Path: Set the path to Leelaz here. In my case, it is /home/clay/Go/leela-zero/build/leelaz
  • No arguments: Fill in the parameters you want


The parameter part is a bit more complicated, you can directly refer to my fill:

-g --noponder -p 1 -w /home/clay/Go/leela-zero/best-network

-p is the number of playouts. Basically, the larger the number, the better the AI.
-w is followed by the weight file you want to use.

The meaning of the parameters are listed below, you can refer to it:

Leave a ReplyCancel reply

Exit mobile version