The Stories behind Jetson Engine

 

About Jetson Lc0 (Jetson Engine v1): Running Leela Chess Zero on a Portable GPU Device

5/31/2020

Hello there! 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. However, 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.

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

I need to figure out the following three points to make this work:

1. Launch lc0 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: For this point, I need to create a data communication channel to transmit the UCI commands to the backend lc0 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). With my dad's help it took me 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.

 

Backend lc0 engine running on the Jetson Xavier NX device and frontend ChessBase UCI engine

 

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.

Laptop connected to the Jetson Xavier NX Device with a case

 

Laptop connected to the Jetson Xavier NX Device without a case

 

Jetson Xavier NX Device with and without a case

 

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

You can find instructive guides on the DIY Jetson Lc0 page.

 

About Jetson Engine v2: Client-Server Framework for Remote Engine Access and Sharing

6/28/2020

The concept of ChessBase accessing lc0 on an external GPU device through direct connection is, in fact, a client-server framework. We realized that the same concept can be extended and applied to other network environments like home WiFi network or even cloud. After v1 was released in May, we immediately started to work on v2.

After three weeks of extensive work, we are very proud to release v2. Not only does the new version continue to support lc0 running externally on a portable Xavier device, but it also now supports all other UCI-compliant engines (Stockfish, Fat Fritz, 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.

More information about how to use v2 can be found here. The packages can be downloaded here. Enjoy!