Skip to content

Commit

Permalink
Merge pull request #506 from killerducky/v0p8rc1
Browse files Browse the repository at this point in the history
v0.8 RC1
  • Loading branch information
killerducky authored May 3, 2018
2 parents 81b8c66 + 2333efc commit ca8fbfc
Show file tree
Hide file tree
Showing 83 changed files with 7,882 additions and 1,488 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ if (APPLE)
include_directories ("/System/Library/Frameworks/Accelerate.framework/Versions/Current/Headers")
endif ()

file (GLOB lczero_SRC "${SrcPath}/*.cpp" "${SrcPath}/*.h")
file (GLOB lczero_SRC "${SrcPath}/*.cpp" "${SrcPath}/*.h" "${SrcPath}/syzygy/*.cpp" "${SrcPath}/syzygy/*.h")

set (lczero_MAIN "${SrcPath}/main.cpp")
file (GLOB lczero_SRC "${SrcPath}/*.cpp")
file (GLOB lczero_SRC "${SrcPath}/*.cpp" "${SrcPath}/syzygy/*.cpp")
list (REMOVE_ITEM lczero_SRC ${lczero_MAIN})

# Reuse for lczero and gtest
Expand Down
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ FROM ubuntu:16.04
RUN apt-get -qq update
RUN apt-get install -y cmake g++
RUN apt-get install -y libboost-all-dev libopenblas-dev opencl-headers ocl-icd-libopencl1 ocl-icd-opencl-dev zlib1g-dev

RUN mkdir -p /src/gpu/
RUN mkdir -p /src/cpu/
RUN apt-get install -y clinfo python3-pip python3-dev
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade tensorflow
RUN clinfo
RUN python3 -V
RUN pip3 -V
COPY . /src/

# GPU build
Expand All @@ -19,3 +22,8 @@ WORKDIR /src/cpu/
RUN CXX=g++ CC=gcc cmake -DFEATURE_USE_CPU_ONLY=1 ..
RUN cmake --build . --config Release -- -j2
RUN ./tests

# PYTHON tests
WORKDIR /src/training/tf/
RUN python3 chunkparser.py
RUN python3 shufflebuffer.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ A central server uses these self-play game data as inputs for the training proce

The weights from the distributed training are downloadable from http://lczero.org/networks. The best one is the top network that has some games played on it.

Weights that we trained to prove the engine was solid are here https://github.com/glinscott/lczero-weights. Currently, the best weights were obtained through supervised learning on a human dataset with elo ratings > 2000.
Weights that we trained to prove the engine was solid are here https://github.com/glinscott/lczero-weights. The best weights obtained through supervised learning on a human dataset were with elo ratings > 2000.

# Training a new net using self-play

Expand Down
4 changes: 2 additions & 2 deletions go/src/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"client/http"

"github.com/notnil/chess"
"github.com/Tilps/chess"
)

var HOSTNAME = flag.String("hostname", "http://162.217.248.187", "Address of the server")
Expand Down Expand Up @@ -78,7 +78,7 @@ func getExtraParams() map[string]string {
return map[string]string{
"user": *USER,
"password": *PASSWORD,
"version": "7",
"version": "8",
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/src/server/templates/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<a class="nav-link" href="/training_data">Training Data</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/?full_elo=1">Full ELO Graph</a>
<a class="nav-link" href="/?full_elo=1">Full Elo Graph</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://discord.gg/pKujYxD">
Expand Down
2 changes: 2 additions & 0 deletions lc0/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
testdata/
LC0VSProj/
CUDA_NN/
22 changes: 22 additions & 0 deletions lc0/LC0VSProj/LC0VSProj.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LC0VSProj", "LC0VSProj.vcxproj", "{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}.Debug|x64.ActiveCfg = Debug|x64
{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}.Debug|x64.Build.0 = Debug|x64
{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}.Release|x64.ActiveCfg = Release|x64
{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
161 changes: 161 additions & 0 deletions lc0/LC0VSProj/LC0VSProj.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\chess\bitboard.cc" />
<ClCompile Include="..\src\chess\board.cc" />
<ClCompile Include="..\src\engine.cc" />
<ClCompile Include="..\src\main.cc" />
<ClCompile Include="..\src\mcts\node.cc" />
<ClCompile Include="..\src\mcts\search.cc" />
<ClCompile Include="..\src\neural\cache.cc" />
<ClCompile Include="..\src\neural\factory.cc" />
<ClCompile Include="..\src\neural\loader.cc" />
<ClCompile Include="..\src\neural\network_mux.cc" />
<ClCompile Include="..\src\neural\network_random.cc" />
<ClCompile Include="..\src\neural\writer.cc" />
<ClCompile Include="..\src\optionsparser.cc" />
<ClCompile Include="..\src\selfplay\game.cc" />
<ClCompile Include="..\src\selfplay\loop.cc" />
<ClCompile Include="..\src\selfplay\tournament.cc" />
<ClCompile Include="..\src\uciloop.cc" />
<ClCompile Include="..\src\utils\commandline.cc" />
<ClCompile Include="..\src\utils\optionsdict.cc" />
<ClCompile Include="..\src\utils\random.cc" />
<ClCompile Include="..\src\utils\transpose.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\chess\bitboard.h" />
<ClInclude Include="..\src\chess\board.h" />
<ClInclude Include="..\src\engine.h" />
<ClInclude Include="..\src\mcts\callbacks.h" />
<ClInclude Include="..\src\mcts\node.h" />
<ClInclude Include="..\src\mcts\search.h" />
<ClInclude Include="..\src\neural\cache.h" />
<ClInclude Include="..\src\neural\factory.h" />
<ClInclude Include="..\src\neural\loader.h" />
<ClInclude Include="..\src\neural\network.h" />
<ClInclude Include="..\src\neural\network_cudnn.h" />
<ClInclude Include="..\src\neural\network_mux.h" />
<ClInclude Include="..\src\neural\network_random.h" />
<ClInclude Include="..\src\neural\network_tf.h" />
<ClInclude Include="..\src\neural\writer.h" />
<ClInclude Include="..\src\optionsparser.h" />
<ClInclude Include="..\src\selfplay\game.h" />
<ClInclude Include="..\src\selfplay\loop.h" />
<ClInclude Include="..\src\selfplay\tournament.h" />
<ClInclude Include="..\src\uciloop.h" />
<ClInclude Include="..\src\utils\bititer.h" />
<ClInclude Include="..\src\utils\cache-old.h" />
<ClInclude Include="..\src\utils\cache.h" />
<ClInclude Include="..\src\utils\commandline.h" />
<ClInclude Include="..\src\utils\cppattributes.h" />
<ClInclude Include="..\src\utils\exception.h" />
<ClInclude Include="..\src\utils\hashcat.h" />
<ClInclude Include="..\src\utils\mutex.h" />
<ClInclude Include="..\src\utils\optional.h" />
<ClInclude Include="..\src\utils\optionsdict.h" />
<ClInclude Include="..\src\utils\random.h" />
<ClInclude Include="..\src\utils\transpose.h" />
</ItemGroup>
<ItemGroup>
<CudaCompile Include="..\src\neural\network_cudnn.cu" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{CBA46B8C-63B8-4F7F-A35D-E1464246DC72}</ProjectGuid>
<RootNamespace>LC0VSProj</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)\..\src;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\CUDA_NN\7.1</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;..\CUDA_NN\7.1</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(ProjectDir)\..\src;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\CUDA_NN\7.1</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;..\CUDA_NN\7.1</LibraryPath>
<TargetName>lc0-cudnn</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>cublas.lib;cudnn.lib;cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>cublas.lib;cudnn.lib;cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>echo copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
</CudaCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.1.targets" />
</ImportGroup>
</Project>
26 changes: 26 additions & 0 deletions lc0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Building and running this version of lc0.

Building is not very streightforward, but here's roughly the process:

## Linux

1. (if you want version with tensorflow) Install tensorflow_cc by following steps described [here](https://github.com/FloopCZ/tensorflow_cc).
2. (if you want cuDNN version) Install CUDA and cuDNN.
3. Install ninja and meson
4. Go to lc0/
5. If you decided not to install tensorflow or CUDA, comment out building network_tf.cc and/or network_cudnn.cu from meson.build.
6. Run ./build.sh

## Windows

Building for windows is currently complicated, you can try executeing steps listed [here](https://github.com/glinscott/leela-chess/issues/334#issuecomment-382848569).

Alternatively, you can use pre-built binary:

1. Install CUDA v9.0 (not 9.1)
2. Inscall cuDNN for CUDA v9.0
3. Take latest binary from [here](https://crem.xyz/lc0/)

That's it.

For the cudnn (non-TF) version, building is much simpler. Install latest CUDA toolkit and compatible cuDNN, and build using the visual studio project.
3 changes: 2 additions & 1 deletion lc0/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/bash
#!/bin/bash

rm -fr build
CC=clang CXX=clang++ meson build --buildtype release # -Db_ndebug=true
# CC=clang CXX=clang++ meson build --buildtype debugoptimized -Db_asneeded=false
# CC=clang CXX=clang++ meson build --buildtype debug
cp testdata/* build
cd build
ninja
42 changes: 30 additions & 12 deletions lc0/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('lc0', 'cpp')
# default_options : ['cpp_std=c++17'])

add_global_arguments('-std=c++17', language : 'cpp')
add_global_arguments('-std=c++17', '-Wthread-safety', language : 'cpp')
cc = meson.get_compiler('cpp')

# Installed from https://github.com/FloopCZ/tensorflow_cc
Expand All @@ -26,21 +26,44 @@ tensorflow_cc = declare_dependency(
deps = []
deps += tensorflow_cc
deps += cc.find_library('stdc++fs')
deps += cc.find_library('libcublas', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/'])
deps += cc.find_library('libcudnn', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/'])
deps += cc.find_library('libcudart', dirs: ['/opt/cuda/lib64/', '/usr/local/cuda/lib64/'])
# deps += dependency('libprofiler')

nvcc = find_program('nvcc')
cuda_files = [
'src/neural/network_cudnn.cu',
]

cuda_gen = generator(nvcc,
output: '@[email protected]',
arguments: ['--std=c++14', '-c', '@INPUT@', '-o', '@OUTPUT@', '-I', '../src'],
)

files = [
'src/chess/bitboard.cc',
'src/chess/board.cc',
'src/mcts/node.cc',
'src/mcts/search.cc',
'src/neural/cache.cc',
'src/neural/factory.cc',
'src/neural/loader.cc',
'src/neural/network_tf.cc',
'src/neural/writer.cc',
'src/neural/network_mux.cc',
'src/neural/network_random.cc',
'src/neural/cache.cc',
'src/mcts/search.cc',
'src/mcts/node.cc',
'src/neural/network_tf.cc',
'src/utils/transpose.cc',
'src/utils/commandline.cc',
'src/utils/optionsdict.cc',
'src/utils/random.cc',
'src/engine.cc',
'src/optionsparser.cc',
'src/selfplay/game.cc',
'src/selfplay/tournament.cc',
'src/selfplay/loop.cc',
'src/uciloop.cc',
'src/ucioptions.cc',
'src/utils/transpose.cc',
cuda_gen.process(cuda_files)
]

includes = []
Expand All @@ -60,11 +83,6 @@ test('ChessBoard',
files, include_directories: includes, dependencies: test_deps
))

test('Network',
executable('network_test', 'src/neural/network_test.cc',
files, include_directories: includes, dependencies: test_deps
))

test('HashCat',
executable('hashcat_test', 'src/utils/hashcat_test.cc',
files, include_directories: includes, dependencies: test_deps
Expand Down
2 changes: 2 additions & 0 deletions lc0/src/chess/board.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ MoveList ChessBoard::GeneratePseudovalidMoves() const {
}
} else if (dst_row == 5 && pawns_.get(7, dst_col)) {
// En passant.
// "Pawn" on opponent's file 8 means that en passant is possible.
// Those fake pawns are reset in ApplyMove.
result.emplace_back(source, destination);
}
}
Expand Down
Loading

0 comments on commit ca8fbfc

Please sign in to comment.