Running Leela/Fat Fritz on your notebook (2)

by Evelyn Zhu
7/2/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– with full instructions for the installation.

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...

In my previous article (Running Leela and Fat Fritz on your notebook), I introduced a client-server framework concept that allows a ChessBase application running on any Windows laptop to access a UCI engine running on an external Jetson Xavier NX device. Now I am proud to announce Jetson Engine v2, an extension of v1 (originally called Jetson Lc0) that covers broader usages in an equally simple setup procedure as v1.

The new version continues to support lc0 running externally on a portable Xavier device. It also now supports all other UCI-compliant engines (Fat Fritz, Stockfish, Fritz, Komodo, Houdini, etc.). In v2, ChessBase can also remotely access any of the UCI-compliant engines that are launched from Windows or Linux servers through networks such as home WiFi or Internet.

ChessBase readers and many top players showed considerable interest in my solution, and are asking for more detailed instructions. So here is a user guide on how to set up Jetson Engine v2 on a Xavier device. For greater clarity you can click most images to enlarge.

Jetson Engine v2 User Guide for Nvidia's Xavier Devices

Welcome to the user guide for setting up Jetson Engine v2 on Nvidia's Jetson Xavier NX and Jetson AGX Xavier devices. Please note that Steps 1-3 are to be done on the Xavier device end and that Steps 4-6 are to be done on the laptop client with ChessBase.

1. Prepare the Xavier Device: The Xavier device is running on Ubuntu Linux 18.04 for ARM64. In this user guide, the device has IP address 192.168.55.1 with hostname jxvnx03, and is connected to the client via MicroUSB-to-USB cable. Please follow this special procedure on how to set up the Xavier device and configurations. You will also need to use PuTTY to log in to the Xavier device.

It is recommended to use a dedicated account in the device to hold the engine folder. In this user guide, the account is "jetson" and the home folder is /home/jetson.

2. Copy Backend Package to Xavier Device Home Folder: Download JetsonBackend_Xavier.zip file on your computer and copy it to the Xavier device home folder mentioned in Step 1. Use pscp to copy the zip file by typing the following command:

pscp JetsonBackend_Xavier.zip jetson@192.168.55.1:/home/jetson

Once the package is copied to the Xavier device, unzip it. You should see the subfolder "JetsonBackend" appear. The JetsonBackend folder contains the following contents:

  • Engine agent jetson_agent: An agent is the program that accepts connections from ChessBase clients, and then distributes UCI requests to the backend engines and relays UCI responses back to the clients. The agent is the only program a user needs to run the backend server. In the Xavier device, the agent is jetson_agent.

  • Engine folders: Each engine folder is associated with an engine that can be launched in the server. The folder name (EngineName) must be set in the configuration file (jetson_agent.conf) to link to the actual engine binary to launch. Different folders may use the same type of engine with different configurations.

Note: each engine folder has the engine program in it. Please do not attempt to manually load the engine program since engine programs are automatically loaded by the agent.

Engine configuration file (jetson_agent.conf): The configuration file tells the agent where to look for the engine program and what configuration options to use with it. Detailed information on how to set configuration is in jetson_agent.conf. Here is an example of what the configuration looks like:

Here is an example of what the "JetsonBackend" folder contents look like on the Xavier device:

3. Launch the Backend Agent on the Xavier Device: After the engine backend package is installed in Step 2, you can now launch jetson_agent. First, go into the “JetsonBackend” folder. Then launch the agent by typing "./jetson_agent".

Note: You might run into the following error:

-bash: ./jetson_agent: Permission denied
You will need to add an execute permission to the agent program by running "sudo chmod a+x jetson_agent"

Once the agent is launched, all the configured backend engines will be waiting for connections from ChessBase clients that are able to access it.

Here is some extra information you might find useful:

Agent Loaded Automatically: The backend server is the machine providing services, so you may want the agent to launch automatically when the server is up to avoid having to log in to the server and launch it manually. To achieve this, you may set a cronjob. There are other ways to automatically load the agent.

Agent Loaded in the Background: When manually loading the agent, we suggest loading it in the background. There should be many different ways to load the agent in the background. One possible way is to run "nohup ./jetson_agent &".

4. Collecting ChessBase UCI Engines on Client: Please download JetsonUCI_Xavier.zip, save it anywhere in your laptop (for example, C:\Users\username), and then unzip it. The subfolder "JetsonUCI" should show up. In this folder you will see three UCI engine executables:

  • JRE_XAVIER_192.168.55.1_53352_lc0-cuda.exe: Lc0 engine with a T40 weights file.
  • JRE_XAVIER_192.168.55.1_53353_lc0-cuda-lite.exe: Lc0 engine with a lighter weights file (faster calculations).
  • JRE_XAVIER_192.168.55.1_54453_sf.exe: Stockfish engine.

You may refer to the general user guide to understand the naming of the JRExxx UCI engines.

JRE Engines for Xavier Device

5. Create UCI Engines from ChessBase on the Client: Launch ChessBase and click "Create UCI Engine." Go to the "JetsonUCI" folder where those JRExxx engines were generated. Select one of the engines to prompt ChessBase to issue UCI commands to retrieve engine information. The UCI commands will be relayed to the backend server and the responses will be transferred back. ChessBase actually has no idea the engine is located outside. Repeat this step to load all those JRExxx engines.

Creating UCI engines from JRE executables

6. Launch and Run UCI Engines on Client: In ChessBase, go to "Analysis" -> "Let's Check". The default engine that comes with ChessBase is usually Fritz. To switch, select any of the newly created JRE engines from the "Load engine" box. A JRE engine will run.

Normally, the engine names shown in the "Load engine" box are the "id name" string returned by the engine. The Jetson agent in the backend server intercepted the "id name" string and then added JRExxx string to allow for easy identification of where the engine comes from and what type of engine it is. For example, the real id name for a lc0 engine is "Lc0 v0.26.0-dev+git.dirty" whereas the modified id name is “JRE_XAVIER_192.168.55.1_lc0-cuda##Lc0 v0.26.0-dev+git.dirty”. Anything before "##" is an added JRE string and anything after "##" is the original id name string.

Position evaluations by lc0 running from Xavier backend

Summary

This six-step procedure is a one-time thing. Once the JRExxx UCI engines are loaded into ChessBase, they will stay there and are good to run, provided that the Jetson agent is running in the backend server. Hope you found this process to be simple!

Note: If you would like to load and run your own engines in addition to the three we provide, please refer to the general user guide on how to do so.

Note: If you would rather not go through the steps of setting up the device (Steps 1-3), and simply want to have a device ready to use, then feel free to contact us. We'd be very happy to purchase all the parts needed to set up the device, install all software packages on the device, and mail a complete package to you. After that, all you would need to do is use the provided MicroUSB-to-USB cable to connect the Xavier device to your Windows laptop, power on the device, and then follow Steps 4-6 to download and run the three UCI engine executables.


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.



Topics: Fat Fritz

Evelyn 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.
Discussion and Feedback Join the public discussion or submit your feedback to the editors


Discuss

Rules for reader comments

 
 

Not registered yet? Register

NYTed NYTed 7/9/2020 09:35
Nice to know that this works with other GUIs as well! I used the Windows Backend and was able to setup two machine matches with the Shredder, Banksia, Cutechess, Aquarium, Winboard, and Arena GUIs.
Bipolar Bipolar 7/3/2020 04:57
I can't believe this! It's too complicated, it's to especialists.
adbennet adbennet 7/3/2020 03:39
Next step: Hot swapping, so the laptop can start the analysis, disconnect the usb, reconnect, and retrieve the results.
almostcarlsen almostcarlsen 7/3/2020 03:05
I hope the author can answer my question. I followed the user guide (http://www.ezchess.org/jetson_v2/UserGuide.html) and tried it out on a linux box. It works great. Nice job! The user guide also says this:

"Cloud Access: Some may wonder if it’s possible to access the backend server via Internet. To that we say yes! You can turn on "Port Forwarding" from your home Internet router, and then the ChessBase client can access it from anywhere in the world. Port forwarding is just one method – we’re pretty sure there are other ways for cloud access with better security. Future Jetson Engine versions (perhaps v3…) may add secure access features to allow safe cloud access."

I think this is an excellent idea but the user guide doesn't give much details what to do. There are a bunch of tcp ports listed in the jetson_agent.conf so I guess those are the ports to be forwarded. Just hope the author can explain more about it.
Davidx1 Davidx1 7/3/2020 12:54
I have the reverse problem: I like old engines, the ancient engines.
Why? Because they are tested with the masters of the past: I would like to use 8-bit or dos programs on fritz 17.
Why not recover them? It's a commercial idea.
saito saito 7/3/2020 12:12
So my question to the author is why spend the lump sum on such a device when you can spend a little bit more and have 3 times the performance for a longer duration of time, also without this lengthy installation procedure? @Scorpion She answered this in the first article: "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 1650) tends to crash from overheat"
Zagliveri_chess Zagliveri_chess 7/3/2020 12:11
Publicity stunt.
Attached device makes laptop less portable.
Attached device requires an external power source.
My 600USD laptop has an engine performing at 2900 ELO equivalent. Why do I need 3300 performance? I am barely at 2200. A 2700 GM who can benefit from a better engine can afford a USD1500 laptop equipped with a decent card.
almostcarlsen almostcarlsen 7/2/2020 10:38
@Scorpion29 You made a good point. This tool doesn't seem to give people a nice performance/price ratio although some may find it useful somewhere. Anyway I still think what she did is cool. As a matter of fact, I just found out that her website has put up a very interesting update. It seems now people can build up shareable engines on a Linux or Windows box, "she calls it engine backend", and then people can just access it simultaneously, even by internet. The update shows some chessbase pictures which I can see that those backend engines show up there. I like this idea. I certainly will give it a try on my Linux box where I have a gpu there with a good amount of power. This article seems only focus on that nvidia xavier toy, and according to her website, is one of the three "backends". I'm not sure why she didn't explain more about linux or windows, that to me is surely more useful.
adbennet adbennet 7/2/2020 04:19
Well done, someone has been working hard for the last two weeks. A small point - despite Fat Fritz being mentioned in the title, I don't think the current setup will accommodate running windows engines on the Xavier device?
Scorpion29 Scorpion29 7/2/2020 03:00
I should also point out that this device costs somewhere between 30k to 50k in India, and for the same ceiling price I will get a gaming laptop with the same speed. Some questions to think about. But good job trying to think differently! Stay safe and best wishes.
Scorpion29 Scorpion29 7/2/2020 02:58
There is a basic problem with this concept. For a mere 1000 dollars (maybe not mere but definitely works for this example!) I have a laptop with a GTX 1660TI that runs Fat Fritz and Leela (T40 Nets only ) at 10000 nodes per second. Correct me if I am wrong, but the speeds you are getting with this device is more than 3 times slower than my laptop. Reliability is also a factor - my laptop might last for 10 years, this device maybe 5 years. Also, if you want a cheap solution, Chessbase cloud should always be fine, even if there is lesser variety. So my question to the author is why spend the lump sum on such a device when you can spend a little bit more and have 3 times the performance for a longer duration of time, also without this lengthy installation procedure? Why not do a simpler upgrade rather than buying an extension like this? Of course I am not saying the method stated here is wrong. It is just way too circuitous, and the performance gain is not worth it.
herr_doktor herr_doktor 7/2/2020 02:24
A pleasure to read this follow up article by Ms. Zhu. It's looking likely that both Lc0 and Fat Fritz will gradually outpace Stockfish (https://www.computerchess.org.uk/ccrl/404/). So as the chess world returns to 'normal' will we see professionals carry around an NVidia Jetson AGX Xavier along with the ubiquitous laptop?
1