Skip to content

Ubuntu 16.04 LC0 Instructions

Alexander Lyashuk edited this page May 18, 2018 · 13 revisions

Building instructions for using CUDA backend

For Ubuntu 17.10 and 18.04 see Troubleshooting section

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 /

Create /etc/apt/sources.list.d/nvidia-ml.list with line: deb http://developer.download.nvidia.com/compute/machine-learning/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-get install nvidia-390 nvidia-390-dev

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

Install cuDNN 7.1: sudo apt-get install libcudnn7 libcudnn7-dev

Install ninja and clang: sudo apt install ninja-build clang (UPD: G++ of version 6 or later should also be fine)

Install/upgrade meson sudo pip3 install --upgrade meson

Edit leela-chess/lc0/src/utils/transpose.cc (UPD: Should not be needed anymore) type_t from_idx = 0; to unsigned int from_idx = 0;

Edit leela-chess/lc0/meson.build (UPD: Should not be needed anymore):

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 (UPD: Should not be needed anymore): nvcc = find_program('nvcc') to nvcc = find_program('/usr/local/cuda-9.1/bin/nvcc')

Comment out test section, starts with ### Tests (UPD: Should not be needed anymore)

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

Resulting lc0 is at leela-chess/lc0/build/release/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?
    • If there are further issues with Ubuntu 18.04, please edit wiki

Alternative cuDNN install:

Download

  • cuDNN v7.1.3 Runtime Library for Ubuntu 16.04 (Deb)
  • cuDNN v7.1.3 Developer Library for Ubuntu 16.04 (Deb)
  • cuDNN v7.1.3 Code Samples and User Guide for Ubuntu 16.04 (Deb)

from: https://developer.nvidia.com/rdp/cudnn-download

then run 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