Windows and CUDA

Skip to first unread message

Graham Jones

May 18, 2018, 5:12:03 PM5/18/18
to LCZero
This may be useful to anyone wanting to compile lc0 on Windows. I didn't get that far yet. I spent much of today getting one sample from CUDA working. The painful details are here:
At one point, with a fresh installation of the latest Visual Studio, and a brand new project, I was unable to compile a simple C program because it couldn't find stdio.h.

Alexander Lyashuk

May 18, 2018, 5:22:01 PM5/18/18
to Graham Jones, LCZero
With new meson build system, it should be easier. I'll plan to simplify process a bit more, but for now the process is following:

1. Install CUDA and Cudnn (I used 9.0 but any should work. No integration with MSVS needed)
2. Install MSVS (I used 2015 but 2017 should also work)
3. Install python3
4. Install meson:  "pip3 install --upgrade meson"
5. Edit lc0/build-cuda.cmd
(change paths to your cuda and cudnn files, and update visual studio path and version if it's not 2015 or installed in different location)
6. Run build-cuda.cmd
It will generate msvs project, then pause (hit enter), then build.
7. It should have lc0 built.

You received this message because you are subscribed to the Google Groups "LCZero" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

Graham Jones

May 19, 2018, 3:49:26 AM5/19/18
to LCZero
Thanks. I want to learn to use CUDA for other reasons, so wanted integration with MSVS. I'd suggest swapping 1 and 2 in your list, because, hey, integration might work.

1. Go here and install MSVS 15.6.7.
This is not what I did, I used 15.7.1, but 15.6.7 should be simpler. You may still have problems with MSVS unable to find standard C libraries or the Windows SDK, or using the wrong version of the SDK
2. Install CUDA 9.2


May 23, 2018, 1:39:03 PM5/23/18
to LCZero
You switched to mason which is ok, but there are more things to edit in build-cuda.cmd depending on MSVC version which IMHO made it more difficult to compile. For example, paths are completely different, you can't just replace 2015 with 2017, etc, so vcvarsall.bat first needs to be located which might be difficult for inexperienced ppl. MSBuild location needs also to be edited, etc.
I know you compile using VS2015, but most of the ppl use VS2017 so it makes sense to have the toolchain example in build-cuda.cmd according to VS2017.

Also, I don't get it why you need to compile zlib from scratch? It is much easier adding it to the project through NuGet. There is already up to date zlib static.

Alexander Lyashuk

May 24, 2018, 4:30:24 AM5/24/18
to Pera Kojot, LCZero
Having linux build config and .sln in parallel is a pain. People add files to linux project, hardcode paths to cuDNN into .sln etc, and it don't update config for other OS.
Is nuget the same as vcpkg? Anyway, I tried to fetch zlib from there and it seems that I would have to install something in addition to visual studio. And then I would have to point by build config to it.

As for VS2015 vs VS2017, I agree that having 2017 by default has more sense, I just don't have VS2017 installed, so only can edit config blindly.
You (or anyone else) are welcome to send PR with the change, or separate .cmd for 2017, as you wish.
(eventually I planned that .cmd to probe several popular locations of different versions of VS/Cuda, so people wouldn't have to edit anything).

May 24, 2018, 2:24:54 PM5/24/18
to LCZero
I followed the exact directions below, on a fresh Win 10 install, fully updated, with MSVS 2015 and CUDA 9.0 and Python 3.65, at default locations...
Build-cuda.cmd  keeps erroring out with "cannot find in directory"

Is there a particular location where the repo should be extracted ?
Or any other program to be installed ?

Adam Crawford

Jul 31, 2018, 2:12:37 AM7/31/18
to LCZero
I am trying to compile Leela, however I don't understand how to Edit lc0/build-cuda.cmd. Can someone please explain it to me
Reply all
Reply to author
0 new messages