Skip to content

Ubuntu 16.04 LC0 Instructions

Andy Olsen edited this page May 15, 2018 · 13 revisions

Building instructions for using CUDA backend

TensorFlow build instructions are different and not yet covered here: please add them if you have built TensorFlow support

Create /etc/apt/sources.list.d/cuda.list with line: deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /

Add key: sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub

Install newest driver: sudo apt install nvidia-390 nvidia-390-dev

Install CUDA 9.1: sudo apt-get install cuda nvidia-cuda-toolkit

Download CUDNN: https://developer.nvidia.com/rdp/cudnn-download

Install CUDNN 7.1 sudo dpkg -i libcudnn7_7.1.3.16-1+cuda9.1_amd64.deb libcudnn7-dev_7.1.3.16-1+cuda9.1_amd64.deb libcudnn7-doc_7.1.3.16-1+cuda9.1_amd64.deb

Install ninja and clang: sudo apt install ninja-build clang

Install meson pip3 install meson

Edit leela-chess/lc0/src/utils/transpose.cc type_t from_idx = 0; to unsigned int from_idx = 0;

Edit leela-chess/lc0/meson.build:

Comment out TensorFlow lines:

# Installed from https://github.com/FloopCZ/tensorflow_cc
#tensorflow_cc = declare_dependency(
#  include_directories: include_directories(
#    '/usr/local/include/tensorflow',
#    '/usr/local/include/tensorflow/bazel-genfiles',
#    '/usr/local/include/tensorflow/tensorflow/contrib/makefile/downloads',
#    '/usr/local/include/tensorflow/tensorflow/contrib/makefile/downloads/eigen',
#    '/usr/local/include/tensorflow/tensorflow/contrib/makefile/downloads/gemmlowp',
#    '/usr/local/include/tensorflow/tensorflow/contrib/makefile/downloads/nsync/public',
#    '/usr/local/include/tensorflow/tensorflow/contrib/makefile/gen/protobuf-host/include',
#  ),
#  dependencies: [
#      cc.find_library('libtensorflow_cc', dirs: '/usr/local/lib/tensorflow_cc/'),
#      cc.find_library('dl')
#      cc.find_library('pthread'),
#      cc.find_library('libprotobuf', dirs: '/usr/local/lib/tensorflow_cc/'),
#  ],
#)

and #deps += tensorflow_cc and # 'src/neural/network_tf.cc',

Modify: nvcc = find_program('nvcc') to nvcc = find_program('/usr/local/cuda-9.1/bin/nvcc')

Comment out test section, starts with ### Tests

Build LC0: ./build.sh when you are in leela-chess/lc0 directory

Resulting lc0 is at leela-chess/lc0/build/lc0


Troubleshooting

  • If you have an older cuda/cudnn build already you may need to uninstall it.
  • I (killerducky) wasn't able to get this command to work: sudo apt-get install cuda nvidia-cuda-toolkit. I had to follow the instruction here https://docs.nvidia.com/cuda/cuda-installation-guide-linux. After downloading the local .deb file, I ran these commands:
sudo dpkg -i cuda-repo-ubuntu1604-9-1-local_9.1.85-1_amd64.deb 
sudo apt-get update
sudo apt-get install cuda-9.1
  • Nvidia cuda does not support gcc later than 6:
    • #error -- unsupported GNU version! gcc versions later than 6 are not supported!.
    • I just ignored them and did this: sudo vim /usr/local/cuda-9.1/bin/../targets/x86_64-linux/include/crt/host_config.h and change it to #if __GNUC__ > 10
    • This is probably only a problem because I'm using Ubuntu 17.10?