Leela Chess Zero

597 views
Skip to first unread message

KAROL KIRSON

unread,
Jun 7, 2018, 2:53:25 AM6/7/18
to PicoChess
Can anyone adapt Leela Zero to picoches 0.9n on raspberrypi. I played a few games. A completely different game I recommend.

Al

unread,
Jun 7, 2018, 7:05:13 AM6/7/18
to PicoChess
Hi Karol,

There were many pre-requisites to install before I could get a working lczero binary. I also downloaded the latest weights file containing all its learning to date.
Here it is running on my Raspberry Pi 3+ using Raspbian Stretch:

Al@PicoChess:~/leela-chess $ ./lczero
Using 2 thread(s).
Detecting residual layers...v2...192 channels...15 blocks.
BLAS Core: ARMV6
info string Found 0 wdl tablebases
info string Found 0 dtz tablebases
uci
id name lczero v0.10
id author The LCZero Authors
option name Threads type spin default 2 min 1 max 4
option name Quiet type check default false
option name SyzygyPath type string default syzygy
option name FPU Reduction type string default 0.100000
option name Puct type string default 0.600000
option name SlowMover type spin default 89 min 1 max 2147483647
option name GoNodesPlayouts type check default false
uciok
go
update_root, 0 -> 0 expanded nodes (0.0% reused)
NNCache: 0/0 hits/lookups = 0.0% hitrate, 0 inserts, 0 size
info depth 5 nodes 1 nps 0 tbhits 0 score cp 4 time 790 pv c2c4
info depth 7 nodes 4 nps 1 tbhits 0 score cp 16 time 2191 pv c2c4 c7c5 g1f3
info depth 8 nodes 6 nps 2 tbhits 0 score cp 16 time 2902 pv c2c4 c7c5 g1f3 e7e6
info depth 9 nodes 11 nps 2 tbhits 0 score cp 16 time 5027 pv c2c4 c7c5 g1f3 e7e6 e2e4
stop

info string g4 -> 0 (V: 50.55%) (N: 0.30%) PV: g4
info string f3 -> 0 (V: 50.55%) (N: 0.39%) PV: f3
info string Na3 -> 0 (V: 50.55%) (N: 0.43%) PV: Na3
info string Nh3 -> 0 (V: 50.55%) (N: 0.43%) PV: Nh3
info string h4 -> 0 (V: 50.55%) (N: 0.50%) PV: h4
info string f4 -> 0 (V: 50.55%) (N: 0.60%) PV: f4
info string a4 -> 0 (V: 50.55%) (N: 0.64%) PV: a4
info string b4 -> 0 (V: 50.55%) (N: 0.74%) PV: b4
info string Nc3 -> 0 (V: 50.55%) (N: 0.82%) PV: Nc3
info string h3 -> 0 (V: 50.55%) (N: 1.04%) PV: h3
info string b3 -> 0 (V: 50.55%) (N: 1.06%) PV: b3
info string a3 -> 0 (V: 50.55%) (N: 1.11%) PV: a3
info string d3 -> 0 (V: 50.55%) (N: 1.16%) PV: d3
info string c3 -> 0 (V: 50.55%) (N: 1.99%) PV: c3
info string e3 -> 0 (V: 50.55%) (N: 2.71%) PV: e3
info string g3 -> 0 (V: 50.55%) (N: 3.66%) PV: g3
info string e4 -> 0 (V: 50.55%) (N: 7.71%) PV: e4
info string Nf3 -> 4 (V: 51.44%) (N: 17.34%) PV: Nf3 c5 c4 e6
info string d4 -> 5 (V: 52.02%) (N: 23.36%) PV: d4 Nf6 c4 e6
info string c4 -> 7 (V: 51.72%) (N: 34.00%) PV: c4 c5 Nf3 e6 e4
info string stm White winrate 51.67%

info depth 10 nodes 17 nps 2 tbhits 0 score cp 15 time 7164 pv c2c4 c7c5 g1f3 e7e6 e2e4
bestmove c2c4

When the Engine first loads it takes a few seconds loading before I can enter the UCI command to enter commands.
I’m guessing this pause is the reason I can’t yet run lczero on PicoChess as when I try to load the engine (with a manually built engines.ini containing Stockfish and lczero only) I get a page full of errors when I attempt to change engines from Stockfish to lczero. Jürgen is back from holiday soon, perhaps he can shed some light on it, here’s the errors:

Al@PicoChess:/opt/picochess $ sudo python3 ./picochess.py
Traceback (most recent call last):
File "./picochess.py", line 1155, in <module>
main()
File "./picochess.py", line 807, in main
engine = UciEngine(file=event.eng['file'], uci_shell=uci_shell)
File "/opt/picochess/uci/engine.py", line 73, in __init__
self.engine.uci()
File "/usr/local/lib/python3.5/dist-packages/chess/uci.py", line 684, in uci
return self._queue_command(command, async_callback)
File "/usr/local/lib/python3.5/dist-packages/chess/uci.py", line 662, in _queue_command
return future.result(timeout=FUTURE_POLL_TIMEOUT)
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
return self.__get_result()
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.5/dist-packages/chess/uci.py", line 682, in command
raise EngineTerminatedException()
chess.engine.EngineTerminatedException

Cheers,

Al.

KAROL KIRSON

unread,
Jun 7, 2018, 9:20:58 AM6/7/18
to PicoChess
Thanks, I do not even try. I have a raspberry pi 32 bit system.

michaelb...@gmail.com

unread,
Jun 7, 2018, 9:37:07 AM6/7/18
to PicoChess
This would be a very nice addition to the Pico engine stable !😊

Al

unread,
Jun 12, 2018, 10:49:36 AM6/12/18
to PicoChess
Hi all,

Update:

Jürgen and me are currently stumped. Lczero runs standalone via ‘./lczero’ and under python chess.
As it takes around 15 seconds to initialise and load, Jürgen coded a 20 second delay when selecting the lczero Engine in PicoChess yet it still crashes, it doesn’t make sense.


Al.

Michael Byrne

unread,
Jun 12, 2018, 1:13:35 PM6/12/18
to pico...@googlegroups.com
I have seen this in some engines ( unrelated to the picochess ) where they may require an “isready” command to be sent or else they crash. The standard reply is “readyok” .

Sent from my iPhone
> --
> You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/BSOG6xg27sc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to picochess+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jürgen Précour

unread,
Jun 12, 2018, 3:31:55 PM6/12/18
to PicoChess
Hi Al,

pls dont post that i still not found it ...this will ruin my reputation , hahaha.

I think i found the problem... the "weights.txt" file needs to be on top folder (/opt/picochess) not inside the engines one.
After selecting "lczero"  y need to wait some secs (15?) until y get this "ok engine", and then it seems to work.

Jürgen

Michael Byrne

unread,
Jun 12, 2018, 3:42:59 PM6/12/18
to pico...@googlegroups.com
The weights.txt file is fairly large, especially for the rather pint size amount of  RAM the Pi has , hence the delay. 

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "PicoChess" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picochess+...@googlegroups.com.

Al

unread,
Jun 12, 2018, 3:45:49 PM6/12/18
to PicoChess
Jürgen,

Well done that works a treat, the engine load takes 15-20 seconds. Now to go and get thrashed by it, shame there’s no levels, however the different weights files are different strengths so can be downloaded to suit.

Thanks,

Al.

Michael Byrne

unread,
Jun 12, 2018, 4:05:04 PM6/12/18
to pico...@googlegroups.com
Hi Al,
Sorry for ignorance - where can we download the exe for Pico? Probably should also post the link to the weights , although I do know it’s on Github and can find it easily. Just for others that may not know.
Regards ,
Michael

Sent from my iPhone

Al

unread,
Jun 12, 2018, 4:20:57 PM6/12/18
to PicoChess
Ok, In this game I didn’t use books, however LCZero has its learning to fall back on and I got in a right mess, as I’m not an opening dictionary:


Cheers,

Al.
4CB218A1-659A-4467-88E8-B485E36D79B8.png

Michael Byrne

unread,
Jun 12, 2018, 7:36:19 PM6/12/18
to pico...@googlegroups.com
of course , the engines you compiled are on your Github link under the new releases thread - DUH!  downloading now...


On Tue, Jun 12, 2018 at 4:20 PM, Al <scal...@gmail.com> wrote:
On Tuesday, June 12, 2018 at 9:05:04 PM UTC+1, Michael Byrne wrote:
> Hi Al,
> Sorry for ignorance - where can we download the exe for Pico?  Probably should also post the link to the weights , although I do know it’s on Github and can find it easily.  Just for others that may not know.
> Regards ,
> Michael
>
> Sent from my iPhone
>
> > On Jun 12, 2018, at 3:45 PM, Al <scal...@gmail.com> wrote:
> >
> > Jürgen,
> >
> > Well done that works a treat, the engine load takes 15-20 seconds. Now to go and get thrashed by it, shame there’s no levels, however the different weights files are different strengths so can be downloaded to suit.
> >
> > Thanks,
> >
> > Al.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "PicoChess" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to picochess+unsubscribe@googlegroups.com.

> > For more options, visit https://groups.google.com/d/optout.

Ok, In this game I didn’t use books, however LCZero has its learning to fall back on and I got in a right mess, as I’m not an opening dictionary:


Cheers,

Al.

--
You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/BSOG6xg27sc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picochess+unsubscribe@googlegroups.com.
Message has been deleted

michaelb...@gmail.com

unread,
Jun 12, 2018, 7:48:11 PM6/12/18
to PicoChess
error running laze on the command line

/opt/picochess/engines/armv7l $ ./lczero
./lczero: error while loading shared libraries: libboost_program_options.so.1.62.0: cannot open shared object file: No such file or directory

On Tuesday, June 12, 2018 at 7:36:19 PM UTC-4, Michael Byrne wrote:
of course , the engines you compiled are on your Github link under the new releases thread - DUH!  downloading now...

Al

unread,
Jun 13, 2018, 12:29:27 AM6/13/18
to PicoChess
Hi Michael,

I’ve sent you an email .....

Al.

Topschach Benny

unread,
Jun 14, 2018, 7:52:37 AM6/14/18
to PicoChess
It works great! I use the latest weights-file ~60 MB and it takes, how you said, 10-15 seconds to load the engine. But then it runs :-) I just wonder that this Engine get a search-deep of 16 after a few seconds. I thought Lelaa that Lelaa takes a lot of time to get a depth of 10. Anyway...it works! Thank you for this!

KAROL KIRSON

unread,
Jun 18, 2018, 3:49:38 PM6/18/18
to PicoChess
Leela does not work. I copied Al's files to the armv7l engine catalog. sudo apt install cmake g ++ git libboost-all-dev libopenblas-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev. I added to engines.ini [lczero]
name = lczero v0.10
small = lczero
medium = lczero
large = lczero 0.10
elo = 2700
I added the file weights.txt to the opt / picochess directory. When I choose lczeero engine freezes, I wait but nothing happens.

Michael Byrne

unread,
Jun 18, 2018, 5:58:01 PM6/18/18
to pico...@googlegroups.com
It’s about a 20 second wait - you should hear engine ok message if you have the voice option on. It does work , just not working for you. 

Sent from my iPhone
--
You received this message because you are subscribed to a topic in the Google Groups "PicoChess" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/picochess/BSOG6xg27sc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to picochess+...@googlegroups.com.

Al

unread,
Jun 19, 2018, 6:30:06 AM6/19/18
to PicoChess
Hi Karol,

I suspect there’s either a problem with your ini file or the weights.txt file.

I’m actually out most of the day so am typing this on a bus from memory, if it’s wrong I’ll correct it later when I’m home.

You seem to have access to a terminal so navigate to /opt/picochess/engines/armv7l
Type sudo ./lczero
It should start but stop complaining about a lack of weights file
Then Type sudo ./lczero -w /opt/picochess
It should start correctly now, unless you weights file is wrong, if it’s wrong download another file, don’t unzip or anything, just change its name to weights.txt and copy it /opt/picochess
If it does start correctly then your problem is the ini file. Stop the engine with quit (if it’s still running) and edit the engines.ini file in /opt/picochess
The last entry should similar to this, I’m using Stockfish as the last entry before lczero, yours may be different:

a-stockf]
name = Stockfish 081017
small = stockf
medium = Stockf8
large = Stockfish 8
elo = 3360

[lczero]
name = lczero v0.10
small = lczero
medium = lczero
large = lczero 0.10
elo = 2700

Notice the blank line between the 2 engine entries.

Then try again, all should be well,

Al.

Al

unread,
Jun 19, 2018, 6:32:23 AM6/19/18
to PicoChess
... sorry the engines.ini file is in /opt/picochess/engines/armv7l

That’s the trouble with a small iPhone screen and movement on a bus 😃

Al

KAROL KIRSON

unread,
Jun 19, 2018, 10:55:46 AM6/19/18
to PicoChess
I downloaded weights_421.txt.gz and unzip then I changed name to weights.txt. This is incorrect ?

Al

unread,
Jun 19, 2018, 11:16:34 AM6/19/18
to PicoChess
Don’t unzip, just rename to weights.txt

Al.

KAROL KIRSON

unread,
Jun 19, 2018, 12:59:28 PM6/19/18
to PicoChess
sudo ./lczero
./lczero: error while loading shared libraries: libboost_program_options.so.1.62.0: cannot open shared object file: No such file or directory
 sudo ./lczero -w /opt/picochess

Al

unread,
Jun 19, 2018, 1:09:14 PM6/19/18
to PicoChess
.. Somehow you missed my instructions on my GitHub site (now deleted).

Enter this anywhere and retry:

sudo apt install cmake g++ git libboost-all-dev libopenblas-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev


Al.

KAROL KIRSON

unread,
Jun 19, 2018, 2:37:39 PM6/19/18
to PicoChess
I did it before. I copied the entire line to the .sh file and ran it.
Something was installing. I do not know what could have gone wrong.

KAROL KIRSON

unread,
Jun 19, 2018, 2:45:39 PM6/19/18
to PicoChess
I have some problem with internet. I try install again.

KAROL KIRSON

unread,
Jun 19, 2018, 3:03:20 PM6/19/18
to PicoChess
Now it works great thanks for help Al.
Reply all
Reply to author
Forward
0 new messages