LeelaChessZero / lc0

The rewritten engine, originally for tensorflow. Now all other backends have been ported here.
GNU General Public License v3.0
2.45k stars 530 forks source link

Lc0 v0.25.0 DX12 uses integrated instead of dedicated mobile GPU #1264

Closed Caleb-Kang closed 4 years ago

Caleb-Kang commented 4 years ago

Computer slows down and lags when using Lc0 v0.25.0 DX12

I'm running Lc0 on lichess.org, and when it plays, my computer is very slow and glitchy.

AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx 2.00 GHz

GPU 0

Radeon RX 560X Series

Driver version: 26.20.15019.19000
Driver date:    2/28/2020
DirectX version:    12 (FL 12.0)
Physical location:  PCI bus 1, device 0, function 0

Utilization 0%
Dedicated GPU memory    0.0/4.0 GB
Shared GPU memory   0.0/3.5 GB
GPU Memory  0.0/7.5 GB

GPU 1

AMD Radeon(TM) Vega 8 Graphics

Driver version: 26.20.15019.19000
Driver date:    2/28/2020
DirectX version:    12 (FL 12.1)
Physical location:  PCI bus 4, device 0, function 0

Utilization 5%
Dedicated GPU memory    0.3/1.0 GB
Shared GPU memory   0.1/3.5 GB
GPU Memory  0.3/4.5 GB
Naphthalin commented 4 years ago

As I already explained to you in https://github.com/LeelaChessZero/lc0/issues/1257#issuecomment-623112386, this is to be somehow expected for notebook hardware, which can only deal with so much heat.

First thing to check would be that Lc0 is actually using the dedicated GPU and not the (surprisingly powerful) integrated GPU. Can you please start Lc0 and provide a screenshot of the Task manager under Performance/GPU?

Also please note that the issues are intended for problems with the binary; for getting help on your setup, please join the discord and ask in #help.

Caleb-Kang commented 4 years ago

@Naphthalin Do you want a screenshot of Lc0 using RX 560X or Radeon Vega 8 Graphics. I assume that Vega 8 is integrated because I once tried uninstalling it but it wouldn't budge.

Naphthalin commented 4 years ago

A screenshot where we could see whether it uses the integrated or the dedicated GPU would be helpful -- so start Lc0 search, and make a screenshot of both GPU's tabs in the task manager.

Caleb-Kang commented 4 years ago

I will run ./lc0.exe backendbench and take a screenshot of Task Manager.

Caleb-Kang commented 4 years ago

AMD Radeon(TM) Vega 8 Graphics Radeon RX 560X Series

Caleb-Kang commented 4 years ago

When I use Vega 8, my computer glitches.

Naphthalin commented 4 years ago

Yeah, that's what I expected. 1) it overheats the CPU and 2) the integrated GPU seems to fill your RAM Can you try lc0 --backend-opts=gpu=1 with different numbers 0, 1, 2 for GPU and see whether one of them uses your dedicated GPU?

Also, once #685 is merged this could be a viable solution for your problem; but we definitely should figure out how to use the dedicated GPU by default.

borg323 commented 4 years ago

The order of the gpus depends on what is returned by windows' IDXGIFactory::EnumAdapters which "first returns the adapter with the output on which the desktop primary is displayed. This adapter corresponds with an index of zero."

mooskagh commented 4 years ago

It should be --backend-opts=gpu=1 not --backend-opts=(gpu=1), i know it's confusing. :)

Caleb-Kang commented 4 years ago

When I run ./lc0.exe backendbench --backend-opts=gpu=0, Lc0 uses the integrated GPU. When I run ./lc0.exe backendbench --backend-opts=gpu=1, Lc0 uses the dedicated GPU.

Does anybody know how to make Lc0 use GPU 1 when playing as an Lichess Bot?

Naphthalin commented 4 years ago

Exactly the same, just leave out the backendbench. Best is probably to create a lc0.config which contains the --backend-opts=gpu=1.

Does your computer still lag when Lc0 is used on the dedicated GPU?

Caleb-Kang commented 4 years ago

@Naphthalin No, my computer does not lag at all when using the dedicated GPU. To create a config file, I just create a text document, type backend-opts=gpu=1, and rename it to lc0.config.txt?

mooskagh commented 4 years ago

Not lc0.config.txt but just lc0.config.

Caleb-Kang commented 4 years ago

Ok. In lc0.config do I just add --backend-opts=gpu=1? What should I add if I want to have lc0 use the dedicated GPU, and should I put the config in the same directory as lc0?

mooskagh commented 4 years ago

yes

Caleb-Kang commented 4 years ago

Ok, thanks. It worked!