Page 1 of 1
Using the Optimus GPU on a laptop for Leela Zero
Posted: Sun Jun 24, 2018 12:14 pm
by macelee
I have been troubled by this for quite a while and could not find a solution.
My new laptop comes with a NVidia card. It is the so-called Optimus setting: the integrated GPU with the Intel processor handles day to day jobs, and the NVidia card can be used to do more intensive jobs.
I have installed Fedora 28 Linux on this machine. I then installed Bumblebee, which supplies the driver for the NVidia card, and a means to switch to the NVidia card to run applications. This appears to work well.
But I have no idea how to use the GPU on this machine to run Leela Zero. Has anyone tried this before?
I was troubled by the poor performance of using the Intel CPU to run LZ. I knew it would be poor. But I was quite shocked when I tried LZ with a 10-year-old NVidia card on a very old desktop PC - the old machine was about 4 times faster.
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Sun Jun 24, 2018 4:24 pm
by sorin
Sorry I don't exactly have an answer to your question, but just one idea to look for: make sure you have installed the OpenCL driver for Nvidia, since I think LeelaZero can only make use of your Nvidia GPU via OpenCL.
The other kind of GPU driver that Nvdia may use is CUDA, but LeelaZero doesn't use that (yet:
https://github.com/gcp/leela-zero/issues/211).
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Sun Jun 24, 2018 11:03 pm
by pnprog
You should check what LeelaZero is saying when you run it a terminal (
./leelaz -w weights.txt). Here is what I get, it's clear what GPU is used (it's also clear I have only one to use):
Code: Select all
Initializing OpenCL.
Detected 1 OpenCL platforms.
Platform version: OpenCL 1.2 CUDA 9.1.84
Platform profile: FULL_PROFILE
Platform name: NVIDIA CUDA
Platform vendor: NVIDIA Corporation
Device ID: 0
Device name: GeForce GT 720M
Device type: GPU
Device vendor: NVIDIA Corporation
Device driver: 390.25
Device speed: 1550 MHz
Device cores: 2 CU
Device score: 1112
Selected platform: NVIDIA CUDA
Selected device: GeForce GT 720M
with OpenCL 1.2 capability.
Then, if it's not the expected GPU, try this, to tell LZ to use others GPU, until you get the expected GPU:
Code: Select all
./leelaz -w weights.txt --gpu 0
./leelaz -w weights.txt --gpu 1
./leelaz -w weights.txt --gpu 2
sorin wrote:Sorry I don't exactly have an answer to your question, but just one idea to look for: make sure you have installed the OpenCL driver for Nvidia, since I think LeelaZero can only make use of your Nvidia GPU via OpenCL.
I agree with this one.
On my Ubuntu, I have to also install the latest nvidia driver (nvidia-390), even though my nvidia card only really requires and uses an older version (nvidia-340). Installing the latest driver must somehow install some tool/framework/idontknowwhat that helps unlocking the latest OpenCL.
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Mon Jun 25, 2018 1:02 am
by macelee
So I must have a problem with the OpenCL driver. This is LZ's output:
Code: Select all
Detecting residual layers...v1...192 channels...15 blocks.
Initializing OpenCL.
Detected 2 OpenCL platforms.
Platform version: OpenCL 1.2 pocl 1.1 RelWithDebInfo, LLVM 6.0.0, SPIR, SLEEF, DISTRO, POCL_DEBUG
Platform profile: FULL_PROFILE
Platform name: Portable Computing Language
Platform vendor: The pocl project
Device ID: 0
Device name: pthread-Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Device type: CPU
Device vendor: GenuineIntel
Device driver: 1.1
Device speed: 4000 MHz
Device cores: 8 CU
Device score: 512
Platform version: OpenCL 1.1 Mesa 18.0.5
Platform profile: FULL_PROFILE
Platform name: Clover
Platform vendor: Mesa
Error getting device(s): clGetDeviceIDs: -1
Selected platform: Portable Computing Language
Selected device: pthread-Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
with OpenCL 1.2 capability.
The output contains this error message:
Code: Select all
Error getting device(s): clGetDeviceIDs: -1
Any idea what caused this?
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Mon Jun 25, 2018 2:15 am
by pnprog
Most probably an issue with your Nvidia driver.
As a first step, check what version of the driver is currently running. This could be that you are running the opensource driver ("nouveau").
On ubuntu (but I guess it will work on fedora as well), you can type:
Code: Select all
lspci -vnn | grep -A 12 '\''[030[02]\]' | grep -Ei "vga|3d|display|kernel"
On my computer with a proprietary Nvidia driver, I get:
Code: Select all
00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09) (prog-if 00 [VGA controller])
Kernel driver in use: i915
Kernel modules: i915
01:00.0 3D controller [0302]: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] [10de:1140] (rev a1)
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_390, nvidia_390_drm
One can see that both
nouveau and
nvidia_390 are installed, but
nvidia is in use.
One a computer using
nouveau, the result would be like this:
Code: Select all
00:0d.0 VGA compatible controller [0300]: NVIDIA Corporation C61 [GeForce 6150SE nForce 430] [10de:03d0] (rev a2) (prog-if 00 [VGA controller])
Kernel driver in use: nouveau
Kernel modules: nouveau, nvidiafb
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Mon Jun 25, 2018 4:12 am
by macelee
Thank you for your advice. I can see a problem in my case. This is my output if running the same command line:
Code: Select all
lspci -vnn | grep -A 12 '\''[030[02]\]' | grep -Ei "vga|3d|display|kernel"
00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 620 [8086:5917] (rev 07) (prog-if 00 [VGA controller])
Kernel driver in use: i915
Kernel modules: i915
02:00.0 3D controller [0302]: NVIDIA Corporation GP108M [GeForce MX150] [10de:1d10] (rev ff) (prog-if ff)
Kernel modules: nouveau, nvidia_drm, nvidia
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi
Also I found the following from the unfiltered output:
Code: Select all
02:00.0 3D controller [0302]: NVIDIA Corporation GP108M [GeForce MX150] [10de:1d10] (rev ff) (prog-if ff)
!!! Unknown header type 7f
Kernel modules: nouveau, nvidia_drm, nvidia
Any suggestions? Thanks again!
Re: Using the Optimus GPU on a laptop for Leela Zero
Posted: Mon Jun 25, 2018 6:02 am
by pnprog
Well, I now believe your computer is using the nouveau driver, and that you should try to install the latest nvidia proprietary driver, then remove the nouveau driver.
It's better if you refer to the Fedora documentation for that as I have no experience with Fedora. With Ubuntu, it's a pretty straightforward process, I guess it should be easy for Fedora as well.