Lc0 - macOS binary requested

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Lc0 - macOS binary requested

Post by MikeB »

Steppenwolf wrote: Tue May 21, 2019 7:38 am Dear MikeB,

Great thanks! :D
I am ready for it.

Please think, that I am not that programmer expert. I have Mojave 10.14.5 and a macbook pro (mid 2014) with no CUDA Driver.
Is there already one for Mojave?
If you need further Information...

Let us now start step by step with a detailed Instruction....
If you want to do this and use your very nice GPU, you will need to go back to High Sierra. macOS 10.13.6

https://www.nvidia.com/object/macosx-cu ... river.html - to use Lc0 without the full face of your GPU will be very frustrating and you would have CPU mode only which is hideously slow with Lc0 and I cannot in good conscious take you down that route for you to get 10 or 15 nodes per second ( not sure what the number is , but it will be below 100 for sure). One can say Apple and LcO do not really play nice with each other. Dowgrading your OS is not fun either and usually not recommended. Your best bet is to pick up a used Macbook Pro - your exact model for $699 from here

https://ipowerresale.com/product/15-mac ... 14-cto-bc/? and under software options , choose macOS 10.13 High Sierra. Never upgrade the OS in this machine until you know the cuda driver for Mojave is available.
Image
Steppenwolf
Posts: 75
Joined: Thu Jan 31, 2019 4:54 pm
Full name: Sven Steppenwolf

Re: Lc0 - macOS binary requested

Post by Steppenwolf »

Hi MikeB,

ok, I understand the Problem.Thanks for your answer.
Honestly, I do not want to go back to macOS 10.13.6.-:(

But, I saw that there is also the possiblity to use the OpenCL-Backend in Lc0.
What do you think about that? Make that sense to use this OpenCL with a good GPU power under Mojave?
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Lc0 - macOS binary requested

Post by MikeB »

Steppenwolf wrote: Thu May 23, 2019 9:25 am Hi MikeB,

ok, I understand the Problem.Thanks for your answer.
Honestly, I do not want to go back to macOS 10.13.6.-:(

But, I saw that there is also the possiblity to use the OpenCL-Backend in Lc0.
What do you think about that? Make that sense to use this OpenCL with a good GPU power under Mojave?
We can try - let's back make sure you have a clean backup to go back to - just in case.

First step - let's install Xcode from the Mac App store:

https://developer.apple.com/xcode/resources/ ( just click on the view in Mac App Store , download and install)
Image
Steppenwolf
Posts: 75
Joined: Thu Jan 31, 2019 4:54 pm
Full name: Sven Steppenwolf

Re: Lc0 - macOS binary requested

Post by Steppenwolf »

Thanks!
Done!

You can write more steps what to do, but layer by layer -:)
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Lc0 - macOS binary requested

Post by MikeB »

Steppenwolf wrote: Fri May 24, 2019 10:15 am Thanks!
Done!

You can write more steps what to do, but layer by layer -:)
Lets get MacPorts:

https://www.macports.org/install.php

make sure you pick the Mojave file:
https://distfiles.macports.org/MacPorts ... Mojave.pkg

1.Double click the pkg file in your download folder and follow the instructions. A quick way to switch to the download folder is have a finder window in focus, hold the option and command keys down simultaneously and select the L key.

2. Install the Apple's Command line developer tools by typing "xcode-select --install" in a terminal window. Agree to the xcode licence by typing "xcodebuild -license" follow the instructions , i.e., hit the return key until it says to type the acceptance.

3. From the terminal. lets do "sudo port selfupdate" followed by "sudo port upgrade outdated" using sudo, it will ask you for your apple password and the cursor will not move or display anything as you type - that's ok. It gives you 3 tries to get it right.

4. Before even using MAcPorts , lets get the Mojave SDK headers , type "installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /" in the terminal window.

5. In the terminal window, we will be installing 3 packages using MacPorts:
type " sudo port install python37", followed by "sudo port install meson", followed by "sudo port install ninja".
Grab a cup of coffee, they may take a while.
Image
Steppenwolf
Posts: 75
Joined: Thu Jan 31, 2019 4:54 pm
Full name: Sven Steppenwolf

Re: Lc0 - macOS binary requested

Post by Steppenwolf »

I did all the things you mentioned.
Everything worked properly to my feeling.

Please go ahead...
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Lc0 - macOS binary requested

Post by MikeB »

Steppenwolf wrote: Fri May 24, 2019 4:54 pm I did all the things you mentioned.
Everything worked properly to my feeling.

Please go ahead...

awesome - next we will grab the source , but before grabbing the source, let's create a folder for it - sincere we will be pulling the source from GitHub and at some point you may want to pull other chess engine sources from Github , will make a Github directory off your home and sub directory lc0 in the Github folder..

typically, when you start terminal window under macOS, it puts you right in the home directory

Mac-Pro:~ your_ user_name_here$

so lets begin by typing at the command prompt in terminal all one one line You can copy and paste:

Code: Select all

mkdir Github && cd Github && mkdir Lc0 && cd Lc0
type "pwd" and you will see you created the path of "Mac-Pro:~ your_ user_name_here/Github/Lc0$
perfect

now lets grab the latest stable release source 21.1 - copy and paste this into terminal:

Code: Select all

git clone  --recurse-submodules https://github.com/LeelaChessZero/lc0.git v0.21.1
it will create another subfolder "v0.21.1" under Lc0. so let go to that folder in terminal by typing "cd v0.21.1" ( or copy and paste)

now if you type "pwd" ( Path of Working Directory) you will see this:

Code: Select all

/Users/your_user_name_here/Github/LcO/v0.21.1
copy that line and click on a finder window toactivtate its menu , select on the menu >Go>Go To Folder and paste the line you just copied.

You will ow see a finder window with all of the sources of LcO which you had just downloaded. You will see a file called "build.sh".

Just to be safe , we need to take sure we build this with clang and not gcc.

copy and paste in the terminal (under the v0.21.1 folder):

Code: Select all

CC=clang CXX=clang++ ./build.sh
As I was typing this, I was replicating the steps on my computer to make sure it will work. I obtained working copy of lc) - you may not, your MacBok Pro might be missing some dependancies - give it a shot and if it errors out , post the entire log message

If you see this

Code: Select all

21 warnings generated.
[52/52] Linking target lc0.
~/Github/Lc0/v0.21.1
you're personal copy of LcO is under ~/Github/Lc0/v0.21.1/build/release folder "lc0" I would start with this NN first :

https://github.com/dkappe/leela-chess-w ... 58-32x4-se - it's not too big, place it in the same folder you are going to run lc0 - for starters , I would run lc0 in the release folder first ( to work out any bugs - before moving it to another folder) via terminal simply type "lc0" ( BUT make sure you copied the weights over to this foilder. No need to unzip the weights file or anything, changing the name to just "weights" and lc0 will find it instantly. Once you start lc0, type uci to see what type of backend you can run whether it's OpenCL , blas or both. If you don't see OpenCL at first , there are other steps we can try to get that for you. OpenCL will be about 100 times faster than blas.
Image
smcracraft
Posts: 737
Joined: Wed Mar 08, 2006 8:08 pm
Location: Orange County California
Full name: Stuart Cracraft

Re: Lc0 - macOS binary requested

Post by smcracraft »

I have this up and running on AWS in Ubuntu and Windows 10 instances using a GPU each.

I'd say it is playing at 3000+ or so.

Didn't bother with my monster-Mac (the top of the product line from Apple) as I don't have a GPU and don't want something lesser.

In one of my own games against my own (weak) grandmaster program "Talish" (on a single thread on my Mac, just a shade over 2500),
I handed off my personal losing side against Talish over to Leela to see if it could recover my position.

Leela promptly sac'ed the exchange and went on to a positional advantage for no immediate material or clear (to me) positional
gain so that was a bit of fun.

For more fun, be sure to watch IM Rudolf analyze the 4-pawn sac of DeepMind AlphaZero against Stockfish in a very entertaining game here:

https://youtu.be/nPexHaFL1uo

But for more fun, see how brittle the new concepts are if you have these programs play without their queen from the starting position.
It's laughable as they have not been trained in those search spaces.

Brittle!
Steppenwolf
Posts: 75
Joined: Thu Jan 31, 2019 4:54 pm
Full name: Sven Steppenwolf

Re: Lc0 - macOS binary requested

Post by Steppenwolf »

Hi MikeB,

great thanks!!!
It seems to work, see my screen shot.
Where can I see the kn/seconds?
They were not displayed in the Output like under SF.
smcracraft
Posts: 737
Joined: Wed Mar 08, 2006 8:08 pm
Location: Orange County California
Full name: Stuart Cracraft

Re: Lc0 - macOS binary requested

Post by smcracraft »

After installing all the pre-requisites on my Mac, it gives this. Thoughts anyone?

Stuarts-MacBook-Pro:macosx stuartcracraft$ git clone https://github.com/LeelaChessZero/lc0.git
Cloning into 'lc0'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 6346 (delta 3), reused 7 (delta 1), pack-reused 6334
Receiving objects: 100% (6346/6346), 35.20 MiB | 972.00 KiB/s, done.
Resolving deltas: 100% (4592/4592), done.
Stuarts-MacBook-Pro:macosx stuartcracraft$ cd lc0
Stuarts-MacBook-Pro:lc0 stuartcracraft$ ./build.sh
The Meson build system
Version: 0.49.2
Source dir: /Users/stuartcracraft/src/leela/macosx/lc0
Build dir: /Users/stuartcracraft/src/leela/macosx/lc0/build/release
Build type: native build
Project name: lc0
Project version: undefined
Native C++ compiler: c++ (clang 10.0.1 "Apple LLVM version 10.0.1 (clang-1001.0.46.4)")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Library libprotobuf found: NO
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Dependency protobuf found: YES 3.7.1
Program protoc found: YES (/usr/local/bin/protoc)
Message: updating git submodule libs/lczero-common
Library pthread found: YES
Library dl found: YES
Library libtensorflow_cc found: NO
Found CMake: /usr/local/bin/cmake (3.14.4)
Dependency accelerate found: YES (/System/Library/Frameworks/Accelerate.framework)
Library mkl_rt found: NO
Library mklml found: NO
Library openblas.dll found: NO
Library openblas found: NO

meson.build:205:6: ERROR: Include dir /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers does not exist.

A full log can be found at /Users/stuartcracraft/src/leela/macosx/lc0/build/release/meson-logs/meson-log.txt