Obtaining Leela Zero and other bots

I often times see people check their PC or even their phones and say oh leela likes this move, or crazy stone likes this move. I would love to be able to run some of my own moves and ideas through these bots but I don’t know how to obtain them. So I would like this thread to serve as a way to have people post the bots that you can obtain, free or paid, a description, how they use them, and any other extra information.

Honestly any information would be helpful.

2 Likes

For Leela on a computer, I would suggest getting your favourite editor that supports GTP engines (for example Sabaki) and download the engine-only version from sjeng.

Leela Zero has to be compiled before you can shove it into an editor, but there are easy to follow instructions on the github page (make sure you satisfy the requirements). The same Leela Zero engine can be used with the ELF weights to get ELF.

On an android phone, I recommend the Gridmaster app, in which you can download the Leela Zero engine, as well as GnuGo, Pachi and its native Steenvreter AI’s.

One last recommendation is go review partner, which needs to be compiled (you’ll need python) and does not come with an AI itself, but you can use it to let an AI like Leela Zero review your game. This is probably the most useful tool to have.

5 Likes

Got Sabaki and then went for leela zero…nope I don’t get this at all. I have to do what? Lol computers are not one of my strengths.

1 Like

Unfortunately Leela Zero is one of the more difficult AI’s to install. You will need some developer tools to compile the source code. I can give you step by step instruction for how I installed LZ on a Mac operating system, perhaps some other good Samaritan can do the same for Windows.

Step 1: Get Xcode (this takes up about 10GB of space, but it’s free and afterwards you can uninstall it again)
Xcode comes with the gcc compiler that you need to install LZ.

Step 2: Get homebrew. The easiest way to install this, is by opening Terminal (located in Applications > Utilities) and paste the following code and press enter:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew is a command line tool, so that you can install LZ easily with a command in terminal. It will ask for a confirmation (press enter) and the password to your account, after which it will start installing (might take a while).

Step 3: Go back to terminal and paste the following code in there:

git clone https://github.com/gcp/leela-zero Documents/Go/leela-zero
cd Documents/Go/leela-zero/src
brew install boost
make
curl -O http://zero.sjeng.org/best-network

To explain what all of this is: the first line line downloads the leela-zero source code from github to a folder called leela-zero, inside a folder Go inside your Documents folder, the second line moves terminal inside the leela-zero folder for the installation, the third line installs boost which will make your leela-zero, then the fourth line simply makes your executable and the fifth and last line downloads the latest good network from the sjeng website into the src folder of leela-zero.

Step 4: Test if everything works by typing the following in terminal:

./leelaz --weights best-network

After pressing enter, Leela Zero should start up, which takes a few seconds, and then should display a text version of a goban. If this happens, you know it installed correctly! You can now quit terminal, if you like.

Step 5: Go to the folder Documents/Go/leela-zero/src (you can use finder for this). There should be a file called “best-network” and a file called “leelaz”. I would recommend moving these files to where you want them to live (in my case I put them in the Documents/Go folder directly). Make sure you put both of them in the same folder, though. After you moved them out of the leela-zero folder you can delete the rest of the leela-zero folder: you don’t need it anymore.

Step 6: Now open Sabaki, and open the Manage Engines menu (under Engines in the menubar). Add a new engine with the button, give it the name Leela Zero (or another name of your choosing). Then click on the folder icon and find & open the “leelaz” you just moved in step 5. Finally in the line which should say “No arguments” paste the following code:

-g --weights best-network

You could choose to add more arguments as well (just write them at the end). Some of my favourites are

--noponder

which stops Leela from heating up your cpu when it’s your turn (it also weakens Leela, since she now only thinks during her own turn),

--p 150

which limits Leela to search only 150 playouts deep and thus makes it a little more speedy, and at my level still plenty strong enough to beat me to pulp.

--resign 0

which stops Leela from resigning when she’s losing too much (probably not necessary, but useful if you want to force Leela to keep playing a game she considers hopelessly lost)

Now you can close the Manage Engines window in Sabaki. Then you go to “Attach…” (also under the Engines menu) and attach Leela to one of the players by clicking on one of the triangles next to the Black / White player names. It should now start playing for that player. If you want to follow what Leela thinks, you can toggle the GTP console (also under the Engines menu), and there should be a console that shows things like which moves Leela considers, and winning percentage. If you want Leela to stop playing (for example to play something out yourself), you can select “Detach” from the Engines menu.

Step 7: You can uninstall Xcode again. Probably the easiest way to do this, is by pasting the following in terminal:

sudo /Developer/Library/uninstall-devtools --mode=all

It will ask you for your password, which you can type and press enter again to uninstall.

4 Likes

I recommend getting Lizzie it is a much easier way to access leela zero

5 Likes

You still have to compile leelaz for that though

Not anymore, you don’t even need to unzip the weights file. All automatic now :slight_smile: (on Windows anyway, can’t speak for other OS)

5 Likes

For what it’s worth, there is a desktop version of Leela that plays at a 4 dan out of the box, and you can just install it and run it and you don’t have to do anything complicated with weights/training, etc

https://sjeng.org/leela.html

4 Likes

One question: I’m simply unable to get this to run on Mac OS. I compiled Leelaz, which I can ‘run’ in text mode and configured the location of leelaz in go review partner. The test also shows no error, but when I try to run it, it shows this error
GoReviewPartner

Lizzie didn’t work at all and gets stuck on the ‘loading Leela Zero’ page :frowning:
I might have to work with Leela if I don’t get this figured out somehow

1 Like

I can’t speak to your issues with go review partner, but I can say that the first time lizzie launches it has to run a lengthy analysis of your system on the first launch but once this finishes it should work very quickly from them on.

I haven’t encountered that error myself, so I don’t know how to solve that. Does GRP also not work Leela 0.11?

There’s two things that probably go wrong with Lizzie:

  1. For Lizzie you need a modified version of Leela Zero, namely the next branch from github. When downloading through the command line, make sure you add -b next:

git clone -b next https://github.com/gcp/leela-zero

  1. On my laptop the next branch of Leela Zero couldn’t use the OpenCL drivers, so I had to make it CPU-only. To do this, you open the config.h file in the folder leela-zero/src and comment out the line #define USE_OPENCL (by putting // in front of it), and then compile it.
2 Likes

Hi @Vsotvep

Yes GRP works with Leela 0.11 !! :sunglasses:

– Musash1

1 Like

I know it does, and it should :slight_smile:
But I was wondering if @Kabootle only had problems with Zero, or if any AI gave him an error.

1 Like

I have docker files/containers for leelazero & lizzie

1 Like

Hi,

When I make this in terminal :

$ git clone -b next https://github.com/gcp/leela-zero

I have this response :
fatal: could not create work tree dir ‘leela-zero’: Permission denied

Can you help me ?

1 Like

Ok, it works if I write :

git clone -b next https://github.com/gcp/leela-zero Documents/Go/leela-zero

But after installation (et compilation, et putting the leelaz folder in lizzie folder), when I open
the Lizzie.jar file : I have this message : Leela zero is loading (infinitely)

Some help ?
(I m not a developer; I m just a go player :slight_smile: )

1 Like

This is normal. The first time either of them run, they have a lengthy process of scanning your hardware and optimising their program for use on your computer. Leela zero gives you a bit more information that this is what’s happening but lizzie just wants you to wait lol

So you have the next version of LeelaZero, and compiled it.

  • Are you sure the “leelaz” executable inside your Lizzie folder is this next version?
  • Does the leelaz executable run on its own in terminal? (if no see next step)
  • Are you sure you compiled it without OpenCL? Since a macbook can’t use OpenCL, see my comment above.

As BHydden says, it can take a minute or two if you have an older computer, but in comparison, mine started working in 20 seconds or so, on a relatively new macbook.

1 Like

When I try to double-click on leelaz executable, I see this message in terminal :

Last login: Thu Aug 2 21:06:03 on ttys000
mkdir: /Users/myname/.bash_sessions: Permission denied
touch: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.historynew: No such file or directory
last-mac:~ myname$ /Applications/lizzie/leelaz ; exit;
A network weights file is required to use the program.
logout
Saving session…-bash: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.session: No such file or directory
touch: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.historynew: No such file or directory
-bash: history: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.historynew: cannot create: No such file or directory

...copying shared history...cp: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.history: No such file or directory

...saving history...cat: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.historynew: No such file or directory
-bash: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.history: No such file or directory
-bash: /Users/myname/.bash_sessions/4E741DF2-6BD4-4F4B-AA53-03EE475C2BB7.historynew: No such file or directory
truncating history files...
...completed.
shlock: open(/Users/myname/.bash_sessions/shlock4269): No such file or directory

[Opération terminée]

Do you understand ?

1 Like

Mostly. It’s largely unrelated to leelaz though.
It appears terminal doesn’t have permission to edit its own session files. I have no idea why that happens, but probably you could fix it by deleting the folder (kind of like erasing browser history) or resetting the permissions of the folder. In the link above you can see that you can do this with the command

rm -r ~/.bash_sessions

or with the commands (requires your password)

sudo chown -R $USER ~/.bash_sessions
chmod 700 ~/.bash_sessions

The lines that are relevant to Leela or the following:

last-mac:~ myname$ /Applications/lizzie/leelaz ; exit;
A network weights file is required to use the program.
logout

The problem with double clicking the leelaz file, is that it doesn’t know which weights file it should use (which is basically the configuration for its neural network). So first of all make sure there is a weights file inside the Lizzie folder (it’s probably a file with ‘network’ in the name). If you don’t have a weights file, download it from http://zero.sjeng.org/best-network, rename it to network.gz and move it to the Lizzie folder.

To test LeelaZero, you have to open terminal and run the following code:

~/Applications/lizzie/leelaz -w network.gz

Here I assume that your weights file is called network.gz, but if it has a different name, you should use that one instead.

It should then start up a text-version of a goban in your terminal window. If it doesn’t please keep us updated :slight_smile:

2 Likes