Skip to content

Running lczero with cuda and cudnn under nvidia docker2

Twirrim edited this page Sep 12, 2018 · 7 revisions

If you have nvidia-docker2 installed, it's possible to run lczero under a docker container while still leveraging all the speed advantages of CUDA and cuDNN. See https://github.com/NVIDIA/nvidia-docker for instructions on setting up nvidia-docker2

You'll need a few things:

Dockerfile:

FROM nvidia/cuda:9.2-cudnn7-devel

RUN apt-get update && apt-get dist-upgrade -y && apt clean all
RUN apt-get update && apt-get install -y curl wget supervisor git clang-6.0 ninja-build protobuf-compiler libprotobuf-dev python3-pip && apt-get clean all
RUN pip3 install meson

RUN     mkdir /lczero && \
        cd ~ && \
        git clone -b release --recurse-submodules https://github.com/LeelaChessZero/lc0.git && \
        cd lc0 &&\
        ./build.sh

RUN     cp /root/lc0/build/release/lc0 /lczero && \
        file /lczero/lc0 && \
        chmod +x /lczero/lc0

RUN cd /lczero && \
    curl -s -L https://github.com/LeelaChessZero/lczero-client/releases/latest | egrep -o '/LeelaChessZero/lczero-client/releases/download/v.*/client_linux' | head -n 1 | wget --base=https://github.com/ -i - && \
    chmod +x client_linux


COPY supervisord.conf /etc/supervisor/conf.d/
COPY settings.json /lczero/settings.json
RUN service supervisor start

supervisord.conf:

[program:lczero]
process_name=%(program_name)s_%(process_num)02d
directory=/lczero
command=/usr/bin/nice /lczero/client_linux
user=root
redirect_stderr=true
stdout_logfile=/lczero/log.log
stdout_logfile_maxbytes=100MB
numprocs=1
autostart=true
autorestart=true

Then settings.json, replacing username and password as appropriate:

{"User":"username","Pass":"password"}

Build the container: sudo docker build . -t leela

Then start it up: sudo docker exec -it $(sudo docker run --runtime=nvidia --name leela -it -d leela:latest ) service supervisor start

Clone this wiki locally