Running Leela and Fat Fritz on your notebook

6/14/2020 – Neural network (NN) engines – Leela Chess Zero, Fat Fritz – have become superbly strong, and provide fascinating positional analysis. However, in order to unleash the full power of the NN algorithms, we must use some kind of GPU accelerator device. The problem is that a compact laptop often can’t sustain the running NN engines and will crash. Here is a super elegant solution to this problem!

Fritz 17 - The giant PC chess program, now with Fat Fritz Fritz 17 - The giant PC chess program, now with Fat Fritz

The most popular chess program offers you everything you will need as a dedicated chess enthusiast, with innovative training methods for amateurs and professionals alike.

More...

Jetson Lc0: Leela and Fat Fritz on a portable GPU device

I am 15-year-old WIM Evelyn Zhu. The beautiful game of chess has and continues to be a huge part of my life. At the age of seven, I started playing chess competitively. Since then, I’ve worked my way up to being one of the top players of my age in the USA.

For the past two years, I’ve been more or less settled with the neural network (NN) based Leela Chess Zero (aka Lc0) engine, the open-source implementation of Google DeepMind’s Alpha Zero. It has consistently beaten other engines, most recently winning the 17th season of the TCEC against Stockfish with a score of 52.5 – 47.5. Lc0 is quite fascinating as is seems to show evaluations in a more positional manner, without searching very deep as other non-NN engines do.

The same applies to the NN engine Fat Fritz (FF), which is part of the Fritz 17 package and with which I intend to experiment with in the future. I am in touch with ChessBase, who will be providing me with betas of the upcoming version. They say it is already now a great leap forward in playing strength.

In order to unleash the power of its NN algorithms, we must use some kind of GPU accelerator device, such as Nvidia’s modern GPU GTX 10 or RTX 20 series.

Modern laptops are, in fact, often equipped with the aforementioned devices. The problem is that the compact profile of a laptop often can’t sustain the running of lc0. When it comes to running an engine for purposes such as opening preparation and game analysis, my laptop (with GTX 1050) tends to crash from overheat.

Because of this issue, I started to wonder if there was a way for laptops to connect to an external, portable Nvidia GPU device and, at the same time, still be able to launch the lc0 engine with ChessBase.

I raised this question to my dad, who is familiar with computer peripheral devices, and he told me there is probably a solution. He mentioned that Nvidia recently released a considerably powerful GPU device, the Jetson Xavier NX module, which is intended for IoT purposes such as AI-powered robotics and autonomous vehicles. This new device has 384 NVIDIA CUDA® Cores and 48 Tensor Cores and claims to reach 21 TOPS AI performance. In essence, it is an excellent candidate for running lc0.

He advised me to figure out the following three points to make this work:

  1. Launch lc0/FF engine inside the Xavier NX device: The lc0 source code is mainly Intel x86/amd64 architecture for both Windows and Linux. Even though Jetson Xavier NX is based on ARM64 architecture, it comes with Ubuntu Linux 18.04, so it is possible to recompile the source code.

  2. Launch UCI engine in ChessBase on Windows laptop: Since I still want to use ChessBase on my Windows laptop the same way I did before, I have to create a UCI engine program that can process ChessBase-issued UCI commands. This does not seem very difficult since I can simply borrow the main program from the lc0 source code and only keep the part with UCI loop logics.

  3. Communications between frontend UCI and backend lc0/FF: For this point, I need to create a data communication channel to transmit the UCI commands to the backend lc0/FF engine. Then, I have to return the results back to the frontend UCI engine. This can be done via network programming or serial port programming since Jetson Xavier NX supports both.

After an intensive few weeks of work, I managed to come up with a simple Windows UCI engine program (point 2) as well as the communication mechanism between UCI and lc0 backend (point 3). My dad helped me crack point 1 as it took some effort to tweak and recompile the lc0 source code for ARM64 and CUDA/CUDNN libraries to successfully load it in the Xavier NX device.

With everything in place, I’m able to simply connect the Xavier NX device with a MicroUSB-to-USB cable to my Windows laptop, launch the lc0 engine from the Xavier NX device (via PuTTY, a secure remote login tool), and then load the UCI engine from ChessBase. And that’s it! The performance is great using the popular network 256x20-t40-1541.pb.gz.

Here is a demo video showing how to run the Jetson Lc0 engine.

The Jetson Xavier NX device is small and very convenient to carry. I also managed to put it inside a case that is dedicated to the Jetson Nano development board.

The Jetson Xavier NX Device connectd to my laptop without a case...

... and in the elegant little case built for it.

Whether or not your laptop comes with Nvidia GPU, you can still run Jetson Lc0 to achieve the high performance of lc0 because you are running on an external GPU device.

This portable Leela Chess Zero and Fat Fritz device really solves my laptop crash issue! I am now using this device for any chess analysis that needs an engine’s help. I’m hoping my work will help many other chess enthusiasts who face a similar issue.

Besides Jetson Xavier NX, the same programs can be used on a more powerful Jetson AGX Xavier, which doubles the performance of lc0.

Coming soon: full instructions on installing the Jetson Lc0/FF with ChessBase on your notebook.

About the author

Evelyn Zhu is a Women International Master and U.S. National Master from Long Island, New York. She started playing chess competitively at a young age and has won numerous individual and team championships. She greatly enjoys giving back to the chess community through her work as a tournament organizer, tournament director, and camp coach. Along with chess, Evelyn finds passion in computer science and engineering. As such, she frequently participates in coding competitions and enjoys learning about the potential of computers and AI.



Discuss

Rules for reader comments

 
 

Not registered yet? Register

devash kumar devash kumar 8/26/2020 06:28
how can i used live artificial intellence of leela chess
infinitless infinitless 7/12/2020 01:17
Another thought I had was whether there is any difference between the quality of nodes between Stockfish and LC0? Due to it's core programming Stockfish can easily squeeze out 10x more nodes on just a CPU than LC0 can. So if I buy a portable GPU and LC0 squeezes out the same number of nodes as Stockfish could do without a GPU - then the effort wasn't worth it!
infinitless infinitless 7/11/2020 11:39
I think if one purchases an RTX graphics card, you can't really use it as a portable option as you have to open up your laptop/desktop to install it!
snits snits 6/21/2020 07:53
Another possibility might be an external gpu enclosure like the Razer Core X, but that would be a rather expensive option between the enclosure and a full gpu to put in it.
adbennet adbennet 6/16/2020 05:19
@Leavenfish
My laptop is here. https://support.hp.com/us-en/document/c04950419

I mostly agree with what you say, and for myself I barely use any engine, although I have several available. Mostly I use Stockfish at low depth for quick double-checking of my own ideas, and sometimes an older Arasan because it supports Nalimov tablebases. Engines are quite important for ICCF, though, as one of the other commenters noted.

But speaking about non-elites not needing lc0 or Fat Fritz or any NN. When I was working as a tradesman, the master carpenter first stated that it's not the hammer that matters, but how it's used. Okay. Later though he stated that I needed a better hammer, and I recalled for him his previous statement. He was not amused. The point is that one needs both good skills and good tools. In another scenario, I was playing volleyball and the coach said I needed better shoes. I was wearing good shoes, but they were made for tennis not volleyball. I said that the shoes were not the weakest part of my game, and he had to agree. But he was right after all, and I suffered a severe injury on account of the shoes! Again, one needs both good skills and good tools. Good tools won't compensate for poor skills, but poor tools will exacerbate poor skills.

A further point is that using an engine might hold back our improvement, or it might accelerate it. But unless we give it a try, we don't actually know which one is the case. This is a troublesome question to answer, because the strongest players today became strong before the current tools were available. So we will need to wait some years before the current crop matures and we can draw some conclusions from their progress.

A final point is that at least some of the players experimenting with engines today hope to be elite in the future, and one or two of them will actually make it. So for them it's better if they get comfortable with the cutting edge tools today that they will need tomorrow.
Keshava Keshava 6/16/2020 07:06
I actually agree with Frederic also. For human play these NN engines may have the most to offer. My response was to the author not adding the term 'most' to the phrase "It has consistently beaten other engines". I actually compete at the master level in AI assisted correspondence (through the ICCF) and SF has expanded my knowledge of the opening with plenty of new ideas. However I don't know how many of the other master level players are using Fat Fritz and Lc0 or which ones they analyze the most with.
bareilly bareilly 6/16/2020 04:36
While article is insightful and provide some practical solution to run NN engine on a normal laptop.

I question, what will be the cost of such an external GPU device? Will not running Stockfish 11 for a longer duration or in specific desired positions yield good enough results? Also one can access database of 2700+ GM games and pick improvements in particular variations instead of reinventing the wheel.
EvelynZ EvelynZ 6/16/2020 03:20
@rgorn Thanks for your comment. You're absolutely right that we don't need to modify the engine source code. My early version did modify it, but the next version will keep the engine intact.
rgorn rgorn 6/16/2020 01:34
It's possible to connect an umodified UCI engine running on a remote linux machine to a GUI running on your local Windows desktop without doing any programming. You just need to configure key-based (password-less) SSH authentication from Windows to Linux first. Then you install plink.exe from PuTTY as a new UCI engine in your GUI and add some parameters for this "engine", like:

-ssh -i C:\Users\me\id_ed25519 -no-antispoof me@remote.net /path/to/lc0

This means: use the ssh protocol, login with your ssh key, do not prompt after authentication, and start lc0 on the remote machine right away. After this, plink will forward UCI commands from the GUI over the net to the running engine and return the output of the engine back to the GUI.
wurik wurik 6/15/2020 09:32
Does this mean that lc0 on chessbase cloud is faster and more powerful than on Jetson AGX Xavier? Thank you.
EvelynZ EvelynZ 6/15/2020 06:46
Hi, this is Evelyn. Thanks for all your comments and nice words. Just some background information to address your concerns and questions. Nvidia’s Jetson devices are meant for AI projects (like autonomous vehicles). But we also found it possible to use them as a side project for running chess engines.

About a year ago, since my laptop kept crashing while running lc0, I thought to use Nvidia’s Jetson Nano to externally run the engine. The problem was that Nano could only reach about 100nps performance, which is not even remotely close to what a decent GPU can do, so I didn’t think Nano was a good fit.

This year Nvidia released Jetson Xavier NX, which claims to be 20+ times better than Nano. The result is not too bad. It gives me about 2500nps (with network 256x20-t40-1541). Still far away from mainstream GPU but decent enough for me. With some lighter network it can easily reach several hundred thousand nps. Nvidia's another more powerful Jetson device (AGX Xavier) should reach about 5000nps with the same t40 network.

After all, this is just an interesting project. Hopefully it can be of help for some people in any way. Also, we do have some other possible usages and extensions to this project, which should be published as we have more results.
Leavenfish Leavenfish 6/15/2020 05:04
@adbennet: I can only say that I do not have that problem on my currently aging laptop and I run SF quite often on (usually) just one core. Maybe it was just put together well - never heard of a laptop without a fan! I do believe that the use of anything beyond Stockfish to "to come up with new ideas and methods of handling certain types of positions" is the ago old chimera in chess - average people looking for that one magical book or engine (anything!) that will 'make you into something they currently are not' when only hard work will get you there. At the SuperGM level, every little rating point they can squeeze out of such 'help' is fine - it may affect their results and income...but for 99.9% of the rest of us, it is simply 'chasing the chimera' as I put it. If they feel the need to spend that kind of money to improve their actual chess play, it would surely be more wisely invested elsewhere.Of course, Fredric has a product to sell, I understand that; and would never tell anyone with the money to burn to 'not' spend it as they wish. But I do like to point out the obvious.
adbennet adbennet 6/15/2020 04:25
@TJOffringa - You should offer up a similar how-to on your setup. Since the Xavier NX has an OS (Ubuntu in this case), it could serve equally as well as your desktop. This would be an alternative solution for people traveling.

@Leavenfish - Doesn't running Stockfish suffer from the same overheating problem? My laptop doesn't have a fan. I could see using a similar setup with an R-Pi for running Stockfish.
TJOffringa TJOffringa 6/15/2020 01:52
Interesting setup! I run Leela on my desktop en use Google remote desktop to access it from anywhere with a laptop or even smartphone and this works totally fine. The only difference is that you always need a stable internet connection of course.
Scorpion29 Scorpion29 6/15/2020 09:22
I agree with Frederic here. I have been a vocal critic of NN in the past, but after investing in a good card (RTX 2070 Super) I am reaping the benefits of using them in my analysis. Stockfish can't be taken out of the picture just yet - I admit I use it a lot as well, but it is not generating as many new ideas as LC0 or Fat Fritz for that matter. My only slight qualm is that Fat Fritz is not being updated as regularly as Leela is, with its recent t60 nets proving to be the strongest chess AI in history. If this is taken care, I am sure more and more people will jump onto the NN bandwagon.
Frederic Frederic 6/15/2020 08:33
People, I do not think we are all looking for ways to get more accurate results in extensive engine vs engine matches. Such matches may be vitally important to a small group of engine fans. The point is that a number of top players in the world, in the 2600-2700+ range, are assiduously using neural network engines to come up with new ideas and methods of handling certain types of positions. These engines come up with different, deeply positional ideas. Many world-class players have installed advanced GPU computers, not, I assure you, to prove that Fat Fritz and Leela are 12 points stronger than Stockfisch or Komodo, but in order to go for greater strength and higher ratings for themselves. I know because I advise a number, who are now all deeply interested in Evelyn's Jetson Lc0 mobile solution. None have called to ask "but can it really beat Sockfish?"
John Hartmann John Hartmann 6/14/2020 07:01
Fantastic information! One note: only two threads are needed for Leela or Fat Fritz. More than that is counterproductive... unless you're running dual GPUs, etc.
sshivaji sshivaji 6/14/2020 06:26
Cool project, what is the Nodes per second performance you are getting with this setup? Curious how this compares to a laptop or desktop Nvidia GPU.
Leavenfish Leavenfish 6/14/2020 05:56
For people who have money to throw around. $600-$700 for the two while Stockfish really just as good (and Free) requiring nothing special. I guess we all have our priorities we need to scratch.
HowardGutman HowardGutman 6/14/2020 03:18
Can you tell us how to play games against Fat Fritz, Lco, or Stockfish on the program, and if possible, how to have them provide commentary or moves.
Keshava Keshava 6/14/2020 01:24
Hello Ms. Zhu, thank you for your article.
While Lc0 is very strong it still has not distanced itself from Stockfish. The two engines are close enough that they have each won the last four TCEC superfinals twice each: https://en.wikipedia.org/wiki/Top_Chess_Engine_Championship#Tournament_results_(TCEC)
Also the CCRL, which runs more trials than does TCEC, currently has Lc0 superior only on the Blitz list: https://ccrl.chessdom.com/ccrl/
1