dkappe / a0lite

A neural net chess engine in 95 lines of python
MIT License
73 stars 13 forks source link

Number of threads used #7

Closed fsmosca closed 3 years ago

fsmosca commented 3 years ago

My pc has 4 cores/8 threads, when a0lite is run it will use 4 threads. Is there any way to allow the user to control how many threads it should use?

OfekShochat commented 3 years ago

A0lite's search uses only 1 thread. The neural network library (badgyal) does that

fsmosca commented 3 years ago

Can we control the number of threads used by the the neural network library?

OfekShochat commented 3 years ago

Pytorch utilizes those threads. So you can set a limit with this (from documentation): https://pytorch.org/docs/stable/generated/torch.set_num_threads.html So you can set that in the code

fsmosca commented 3 years ago

Thanks it worked.

I revised the mgnet.py, meangirl_net.py, bgnet.py and badgyal_net.py.

And couple of modifications in engine.py to expose the threads, cuda and net name.

A0 Lite
uci
id name A0 Lite
id author Dietrich Kappe
option name Threads type spin default 1 min 1 max 128
option name UseCuda type check default false
option name NetName type combo default meangirl var badgyal var meangirl
uciok
OfekShochat commented 3 years ago

Cool, that is a cool pr idea, make a branch on your fork

fsmosca commented 3 years ago

Changes are now in the branch

I change Threads to TorchCPUThreads so as not to be confused with the normal engine Threads.

A0 Lite
uci
id name A0 Lite
id author Dietrich Kappe
option name TorchCPUThreads type spin default 1 min 1 max 128
option name UseCuda type check default false
option name NetName type combo default meangirl var badgyal var meangirl
uciok

There are also minor changes in the badgyal package.