Page 1 of 1

Leela zero install on Ubuntu

Posted: Wed Sep 05, 2018 7:57 am
by dsatkas
Can someone explain how i can install Leela on my Ubuntu? I am basically a moron with Linux and the stuff i've seen on Github seem confusing. Any ideas would be appreciated

Re: Leela zero install on Ubuntu

Posted: Fri Sep 07, 2018 1:17 am
by Revilo
Well, this is quite a pain in the neck. What eventually worked on my machine was the procedure Example of compiling and running - Ubuntu described here: https://github.com/gcp/leela-zero

Code: Select all

# Test for OpenCL support & compatibility
sudo apt install clinfo && clinfo

# Clone github repo
git clone https://github.com/gcp/leela-zero
cd leela-zero/src
sudo apt install libboost-dev libboost-program-options-dev libopenblas-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev
make
cd ..
wget http://zero.sjeng.org/best-network
src/leelaz --weights best-network


In an ideal world, you would excecute these commands in the shell and be done with it. In practice, you are very likely going to run into some issues, like missing dependencies. Also very likely, you will have to create symbolic links in e.g. usr/etc and the like.

So let's walk through the commands one-by-one. I hope the following will help you through this maze.

Code: Select all

sudo apt install clinfo && clinfo


The tool clinfo is for GPU diagnostics. It is not needed to run LZ as such. However, you can use it to check if you've got the GPU drivers up and running. Execute the command in the shell and pray that your graphic card is listed as one of the available devices in the command output. If it is not, it's time for specific troubleshooting. Most likely, you will have to install a vendor-provided driver for your GPU. There's also a way to compile LZ without GPU support (see later).

Code: Select all

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


With these commands, you will check out the LZ source code from GitHub. The folder leela-zero will be created by the git tool. In contrast to the command given on the LZ GitHub page, the command here will check out the next branch via the option -b next. This is basically a future release candidate. However, it is both faster and also required to use LZ in Lizzie.

Before you execute these commands, create a directory for self-compiled tools in your home directory and navigate into this directory before checking out. This is not necessary as such but will help you find your stuff more easily, like for example when you need to enter the path to LZ in a Go GUI.

You may find that git isn't installed. In this case the error message should point you to the required actions, very likely something like sudo apt install git. Note, that sudo is used to execute a command with super user rights. You will be prompted to enter the root password.

Once you have succeeded in checking out the source code and navigated into the source directory (second command), you're ready for the real fun.

Code: Select all

sudo apt install libboost-dev libboost-program-options-dev libopenblas-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev


This part of the procedure installs the dependencies. Just hope that you don't run into weird errors, because then it's time for Google, i.e. search Google for the error messages and try to find forum posts describing the remedy. The remedy will usually be something like installing another depencency, editing a configuration file or creating a symbolic link.

Code: Select all

make


Given that the dependencies have been installed properly, this command will build the binary. If you run into errors, some of the remedies mentioned above (symbolic links, configuration file entries...) might help here as well. Before starting over, it's a good idea to do so from scratch by executing the command make clean first.

Code: Select all

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


When the binary has been built successfully, the rest is piece of cake. Navigate to the folder containing the binary and download the current best network weights using wget. That way, the network weights and the binary will be stored in the same folder.

Code: Select all

leelaz --weights best-network


The binary will be called leelaz. It must be executed with the shown command line argument for the weights file. When you configure a Go GUI to use LZ, you might have to prepend the absolute path to the folder where then binary and weight file are located.

EDIT #1:

If you want to build LZ without GPU support, you will have to insert the following line into the file config.h in the directory src.

Code: Select all

#define USE_CPU_ONLY


EDIT #2:

Changed GitHub part to checking out the next branch.

Re: Leela zero install on Ubuntu

Posted: Fri Sep 07, 2018 5:22 pm
by ez4u
One point! Whether you want only Leela Zero or LZ plus Lizzie, you should download and compile the "next" branch of LZ. So see the instructions for Lizzie. On my Mint (Ubuntu varient) machine, the old main branch code runs at least 50% slower than "next".

Re: Leela zero install on Ubuntu

Posted: Sat Sep 08, 2018 1:55 am
by Revilo
Good point. I've updated my post.

Maybe this thread could also be moved to or linked to the Computer Go subforum?

Re: Leela zero install on Ubuntu

Posted: Tue Oct 23, 2018 7:27 pm
by mycophobia
For anyone getting weird errors about missing Eigen/Dense in Ubuntu Bionic as I was today, you can symlink /usr/include/eigen3/Eigen to /usr/include/Eigen, like so:

Code: Select all

sudo ln -s /usr/include/eigen3/Eigen/ /usr/include/Eigen


and then hopefully it'll build! :D

Re: Leela zero install on Ubuntu

Posted: Wed Apr 22, 2020 4:11 am
by GeneOntology
Hi everyone,
Mycophobia, I'm not sure you will still be here but hope so (18 mounth after your post ^^)

I have this exact same error message
"fatal error: Eigen/Dense: No file or folder of this type
compilation terminated."

and i tried your solution but maybe didn't quite get it right

you mean pasting

Code: Select all

sudo ln -s /usr/include/eigen3/Eigen/ /usr/include/Eigen
While still in the leela-zero/src folder?

right now if i paste this wile in the leela-zero/src folder, I get a message saying
"impossible to create the symbolic link '/usr/include/Eigen': the file exists"

which should be good, if it already exists, but when I paste again the command

Code: Select all

make
I still get the fatal error about "Eigen/Dense: no file or folder of this type"

Have i done something wrong?

Thanks to anyone who can help me :)

Re: Leela zero install on Ubuntu

Posted: Tue Apr 28, 2020 5:43 am
by TheLemon
GeneOntology wrote: you mean pasting

Code: Select all

sudo ln -s /usr/include/eigen3/Eigen/ /usr/include/Eigen
While still in the leela-zero/src folder?

"impossible to create the symbolic link '/usr/include/Eigen': the file exists"
With the / in /usr the path is absolute so you can invoke it from any folder.

What are the contents of /usr/include/Eigen compared to /usr/include/eigen3/Eigen? If both are folders with differing contents I would try various variations like:

Code: Select all

sudo ln -s /usr/include/eigen3/Eigen/ /usr/include/Eigen/
sudo ln -s /usr/include/eigen3/Eigen/Dense /usr/include/Eigen
sudo ln -s /usr/include/eigen3/Eigen/Dense /usr/include/Eigen/
sudo ln -s /usr/include/eigen3/Eigen/Dense /usr/include/Eigen/Dense
If /usr/include/Eigen is a file then try deleting it in between the various variations.

This thread: https://askubuntu.com/questions/543516/ ... ists-error
Suggests --force option, ie try ln -sf