Setup Xavier NX and Compile Engine Source Code
Nvidia's Jetson Xavier devices (Xavier NX or AGX Xavier) run on ARM64 CPU architecture, so we need to download chess engine source codes and compile for ARM64. Jetson Engine package contains the compiled binaries for LCZero and Stockfish. Please follow the steps to set up Xavier device and its software. Some special tweaks and work-arounds are needed for a chess engine to load successfully on Xavier devices.
1. Set up Jetson Xavier NX device: Follow Getting Started with Jetson Xavier NX Developer Kit to download the SD card image and install Jetson Xavier NX software packages. During the installations, make sure to create a user account: for example, "jetson."
2. Connect Jetson Xavier NX device: Use a MicroUSB-to-USB cable to connect the Windows laptop (USB send) to the Jetson Xavier NX device (MicroUSB end). Once connected, you should see "USB Serial Device" show up under "Ports (COM & LPT)" in the Windows Device Manager.
3. Log in Jetson device: Launch PuTTY and select "SSH" with IP address 192.168.55.1. This prompts the user to enter the username and password. Jetson Xavier device runs Ubunbu Linux 18.04 and it launches a DHCP service to automatically assign IP address 192.168.55.100 to the USB end on the Windows laptop. It came to our attentions that this address is not stable, perhaps because of some issues related to DHCP service. One solution is to setup static IP address on the Windows end.
4. Patch cuDNN Library: The Ubuntu 18.04 in the Jetson device comes with cuDNN-8 libraries, however, there is a bug in it preventing LCZero engine to load. The work around is to downgrade to cuDNN-7. Here are the procedures:
-
(1) Force remove libcudnn8 and libcudnn8-dev by running:
sudo dpkg --purge --force-all libcudnn8
sudo dpkg --purge --force-all libcudnn8-dev -
(2) Download the following two packages from here:
cuDNN 7.6.4 for Ubuntu 18.04 (libcudnn7_7.6.4.30-1+cuda10.2_arm64.deb)
cuDNN 7.6.4 Tar archive for Linux (cudnn-10.2-linux-aarch64-v7.6.4.30.tgz) -
(3) Copy both files to a folder, for example, /home/jetson, in the Jetson device.
-
(4) Unzip cudnn-10.2-linux-aarch64-v7.6.4.30.tgz, which gives “cuda” folder.
-
(5) Under the /home/jetson folder, run the following commands to install the packages:
sudo dpkg -i libcudnn7_7.6.4.30-1+cuda10.2_arm64.deb
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 -
(6) Go to /usr/local/cuda/lib64 and run the following commands:
sudo ln -s libcudnn.so.7.6.4 libcudnn.so.7
sudo ln -s libcudnn.so.7 libcudnn.so
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* -
(7) Reboot the Jetson Xavier device.
5. Compile LCZero and Stockfish from source codes: Please download source codes from LCZero and Stockfish.
-
LCZero: modify meson.build and change two places from -arch=compute_70 and -code=sm_70 to -arch=compute_72 and -code=sm_72, then follow instructions to compile. You may also need to add the following two lines to /home/jetson/.bashrc file and then either run “source” command or relogin Jetson device to make the environment variables to take effect:
export PATH=${PATH}:/usr/local/cuda/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64 -
Stockfish: set ARCH to armv8 and follow their instruction to compile.
6. Change Default Power Mode: Jetson Xavier NX or AGX Xavier by default doesn't enable the best GPU power mode. Please refer to Jetson Device Supported Modes and Power Efficiency for the avaialble power mode settings. We suggest to use the following command to set power mode 0 for the best GPU performance.
sudo /usr/sbin/nvpmodel -m 0