Package: lczero-bindings
Lc0Lc0 is a UCI-compliant chess engine designed to play chess via neural network, specifically those of theLeelaChessZero project.Downloading sourceLc0 can be acquired either via a git clone or an archive download from GitHub. Be aware that there is a required submodule which isn't included in source archives.For essentially all purposes, including selfplay game generation and match play, we highly recommend using the latestrelease/versionbranch (for examplerelease/0.30), which is equivalent to using the latest version tag.Versioning follows the Semantic Versioning guidelines, with major, minor and patch sections. The training server enforces game quality using the versions output by the client and engine.Download using git:gitclone-brelease/0.30--recurse-submoduleshttps://github.com/LeelaChessZero/lc0.gitIf you have cloned already an old version, fetch, view and checkout a new branch:gitfetch--all
gitbranch--all
gitcheckout-tremotes/origin/release/0.30If you prefer to download an archive, you need to also download and place the submodule:Download the.zipfile (.tar.gzarchive is also available)ExtractDownloadhttps://github.com/LeelaChessZero/lczero-common/archive/master.zip(also available as.tar.gz)Move the second archive into the first archive'slibs/lczero-common/folder and extractThe final form should look like<TOP>/libs/lczero-common/proto/Having successfully acquired Lc0 via either of these methods, proceed to the build section below and follow the instructions for your OS.Building and running Lc0Building should be easier now than it was in the past. Please report any problems you have.Aside from the git submodule, lc0 requires the Meson build system and at least one backend library for evaluating the neural network, as well as the requiredzlib. (gtestis optionally used for the test suite.) If your system already has this library installed, they will be used; otherwise Meson will generate its own copy of the two (a "subproject"), which in turn requires that git is installed (yes, separately from cloning the actual lc0 repository). Meson also requires python and Ninja.Backend support includes (in theory) any CBLAS-compatible library for CPU usage, such as OpenBLAS or Intel's DNNL or MKL. For GPUs, OpenCL and CUDA+cudnn are supported, while DX-12 can be used in Windows 10 with latest drivers.Finally, lc0 requires a compiler supporting C++17. Minimal versions seem to be g++ v8.0, clang v5.0 (with C++17 stdlib) or Visual Studio 2017.Notethat cuda checks the compiler version and stops even with newer compilers, and to work around this we have added thenvcc_ccbinbuild option. This is more of an issue with new Linux versions, but you can get around it by using an earlier version of gcc just for cuda. As an example, adding-Dnvcc_ccbin=g++-9to thebuild.shcommand line will use g++-9 with cuda instead of the system compiler.Given those basics, the OS and backend specific instructions are below.LinuxGenericInstall backend:If you want to use NVidia graphics cards InstallCUDAandcuDNN.If you want to use AMD graphics cards install OpenCL.if you want OpenBLAS version Install OpenBLAS (libopenblas-dev).Install ninja build (ninja-build), meson, and (optionally) gtest (libgtest-dev).Go tolc0/Run./build.shlc0will be inlc0/build/release/directoryUnzip aneural networkin the same directory as the binary.If you want to build with a different compiler, pass theCCandCXXenvironment variables:CC=clang-6.0 CXX=clang++-6.0 ./build.shNote on installing CUDA on UbuntuNvidia provides .deb packages. CUDA will be installed in/usr/local/cuda-10.0and requires 3GB of diskspace.
If your/usr/localpartition doesn't have that much space left you can create a symbolic link before
doing the install; for example:sudo ln -s /opt/cuda-10.0 /usr/local/cuda-10.0The instructions given on the nvidia website tell you to finish withapt install cuda. However, this
might not work (missing dependencies). In that case useapt install cuda-10-0. Afterwards you can
install the meta packagecudawhich will cause an automatic upgrade to a newer version when that
comes available (assuming you useInstaller Type deb (network), if you'd want that (just cuda-10-0 will
stay at version 10). If you don't know what to do, only install cuda-10-0.cuDNN exists of two packages, the Runtime Library and the Developer Library (both a .deb package).Before you can download the latter you need to create a (free) "developer" account with nvidia for
which at least a legit email address is required (their website says: The e-mail address is not made public
and will only be used if you wish to receive a new password or wish to receive certain news or notifications
by e-mail.). Further they ask for a name, date of birth (not visible later on), country, organisation ("LeelaZero"
if you have none), primary industry segment ("Other"/none) and which development areas you are interested
in ("Deep Learning").Ubuntu 18.04For Ubuntu 18.04 you need the latest version of meson, libstdc++-8-dev, and clang-6.0 before performing the steps above:sudo apt-get install libstdc++-8-dev clang-6.0 ninja-build pkg-config
pip3 install meson --user
CC=clang-6.0 CXX=clang++-6.0 INSTALL_PREFIX=~/.local ./build.shMake sure that~/.local/binis in yourPATHenvironment variable. You can now typelc0 --helpand start.Ubuntu 16.04For Ubuntu 16.04 you need the latest version of meson, ninja, clang-6.0, and libstdc++-8:wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main'
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install clang-6.0 libstdc++-8-dev
pip3 install meson ninja --user
CC=clang-6.0 CXX=clang++-6.0 INSTALL_PREFIX=~/.local ./build.shMake sure that~/.local/binis in yourPATHenvironment variable. You can now typelc0 --helpand start.openSUSE (all versions)Instructions, packages and tools for building on openSUSE are atopenSUSE_install.mdDockerUsehttps://github.com/vochicong/lc0-dockerto run latest releases of lc0 and the client inside a Docker container.WindowsHere are the brief instructions for CUDA/CuDNN, for details and other options seewindows-build.md.Install Microsoft Visual Studio (2017 or later)InstallCUDAInstallcuDNN.Install Python3Install Meson:pip3 install --upgrade mesonEditbuild.cmd:SetCUDA_PATHwith your CUDA directorySetCUDNN_PATHwith your cuDNN directory (may be the same with CUDA_PATH)Runbuild.cmd. It will ask permission to delete the build directory, then generate MSVS project and pause.Then either:HitEnterto build it.Resulting binary will bebuild/lc0.exeOr.Open generated solutionbuild/lc0.slnin Visual Studio and build yourself.MacFirst you need to install some required packages through Terminal:Install brew as per the instructions athttps://brew.sh/Install python3:brew install python3Install meson:brew install mesonInstall ninja:brew install ninja(For Mac OS 10.14 Mojave, or if the other step 5 fails):Install developer tools:xcode-select --installWhen using Mojave install SDK headers:installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /(if this doesn't work, usesudo installerinstead of justinstaller.)Or.(For MacOS 10.15 Catalina, or if the other step 5 fails):Install Xcode command-line tools:xcode-select --installInstall "XCode Developer Tools" through the app store. (First one on the list of Apps if searched.)Associate the SDK headers in XCode with a command: export CPATH=`xcrun --show-sdk-path`/usr/includeNow download the lc0 source, if you haven't already done so, following the instructions earlier in the page.Go to the lc0 directory.Run./build.sh -Dgtest=false(needs step 5)Raspberry PiYou'll need to be running the latest Raspberry Pi OS "buster".Install OpenBLASgitclonehttps://github.com/xianyi/OpenBLAS.gitcdOpenBLAS/
make
sudomakePREFIX=/usrinstallcd..Install Mesonpipinstallmeson
pipinstallninjaInstall compiler and standard librariessudoaptinstallclang-6.0libstdc++-8-devClone lc0 and compilegitclonehttps://github.com/LeelaChessZero/lc0.gitcdlc0
gitsubmoduleupdate--init--recursiveCC=clang-6.0CXX=clang++-6.0./build.sh-Ddefault_library=staticThe resulting binary will be in build/releasePython bindingsPython bindings can be built and installed as follows.pipinstall--usergit+https://github.com/LeelaChessZero/lc0.gitThis will build the packagelczero-bindingsand install it to your Python user install directory.
All thelc0functionality related to position evaluation is now available in the modulelczero.backends.
An example interactive session can be foundhere.LicenseLeela Chess is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.Leela Chess is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with Leela Chess.  If not, seehttp://www.gnu.org/licenses/.Additional permission under GNU GPL version 3 section 7The source files of Lc0 with the exception of the BLAS and OpenCL
backends (all files in theblasandopenclsub-directories) have
the following additional permission, as allowed under GNU GPL version 3
section 7:If you modify this Program, or any covered work, by linking or
combining it with NVIDIA Corporation's libraries from the NVIDIA CUDA
Toolkit and the NVIDIA CUDA Deep Neural Network library (or a
modified version of those libraries), containing parts covered by the
terms of the respective license agreement, the licensors of this
Program grant you additional permission to convey the resulting work.