Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 18.04 NVIDIA - GPU stuck on performance level 0 when on battery #501

Open
atasoglou opened this issue May 16, 2019 · 10 comments
Open

Ubuntu 18.04 NVIDIA - GPU stuck on performance level 0 when on battery #501

atasoglou opened this issue May 16, 2019 · 10 comments
Labels

Comments

@atasoglou
Copy link

@atasoglou atasoglou commented May 16, 2019

On surface book 2 with Ubuntu 18.04 using NVIDIA drivers and kernel 5.0.10-surface-linux-surface:

  • When on battery, GPU is stuck on performance level 0, which restricts the GPU to work between 139-607MHz. As a result the whole desktop is laggy, as GPU is constantly at 100% but under-performing because of the frequency restriction.
  • When plugged-in the power, everything is normal, GPU can go up to level 4.

Is this related to the acpi developments maybe?
Tested with NVIDIA drivers 390, 415 and 430 - all same behavior.

@qzed qzed added the D-Book2 label May 17, 2019
@qzed
Copy link
Collaborator

@qzed qzed commented May 17, 2019

First off, I'd generally suggest you use the Intel GPU for your desktop usage, as this will give some considerable power savings, and only use the dGPU for the applications that need the performance, i.e. via optimus.

To set this all up, you basically only need to install https://github.com/qzed/linux-surfacebook2-mshw0153 and optimus. I also recommend you install https://github.com/qzed/linux-surface-control (which provides the surface commend), as this allows you to change the settings (e.g. power-on/off the dGPU more easily). By default the module will disable the dGPU at startup, so that you can later enable it (e.g. via sudo surface dgpu set on) and use it via optimus.

Additionally to that (or if you specifically want the dGPU as main GPU), you can change the performance mode (e.g. sudo surface performance set 4). This won't give you the full power of the dGPU (will always be limited without AC), but should give a good improvement. Here are a bit more details to that.

@atasoglou
Copy link
Author

@atasoglou atasoglou commented May 20, 2019

Yeah, I agree with you. However, my line of work requires the GPU, so I need to stick with it. Normally, while working, I have it plugged in, but if it happens that I need to grab my laptop for a meeting, then it is kinda annoying cause the desktop becomes super laggy.

Anyway, I will try your suggestion with the surface-control. Thanks a lot!!

@qzed
Copy link
Collaborator

@qzed qzed commented May 21, 2019

If you need it for anything graphical, I suggest you look into optimus (if you use cuda, you don't even need that, just select the dGPU). Via optimus, you can use the dGPU for the application that requires it and the iGPU for the rest.

@atasoglou
Copy link
Author

@atasoglou atasoglou commented May 22, 2019

Good advice, thanks! Works in my case, as I need the dGPU mostly for CUDA. So bbswitch+optimus working fine! I am using now Intel for anything graphical.

@ZHG2017
Copy link

@ZHG2017 ZHG2017 commented May 31, 2019

@qzed Hi, sorry to bother you again. I saw in your comments you mentioned that it was not even necessary to use optimus for CUDA coding, did I understand this correctly ? I am interested in coding some CUDA programs so I wonder if I could just activate the integrated GPU with Intel's CPU while coding and testing my CUDA code without the need to switch to dGPU. thank you in advance !

@qzed
Copy link
Collaborator

@qzed qzed commented May 31, 2019

@ZHG2017 Yes, optimus is only necessary for graphics, or more strictly speaking, if you want to render a window on a different GPU.

If you want to do compute stuff, you can use the Intel GPU for your desktop environment etc. and the dGPU for CUDA. Just turning on the dGPU and loading the drivers should work. CUDA will then automatically detect it (since it can't run on the Intel GPU, it's the only GPU it can detect) and should use it without you having to configure anything.

@protosam
Copy link

@protosam protosam commented Jul 25, 2019

With Ubuntu 18.04LTS, I'm getting some rather odd results while testing this all out. nvidia-settings is showing I'm stuck on mode 0 when I unplug the device and the power consumption gets extremely throttled:

Output from nvidia-smi dmon:

# gpu   pwr gtemp mtemp    sm   mem   enc   dec  mclk  pclk
# Idx     W     C     C     %     %     %     %   MHz   MHz
    0    26    65     -     0     0     0     0  4006  1404
    0    26    65     -     6     0     0     0  4006  1404
    0    26    65     -     0     0     0     0  4006  1404
    0    26    65     -     0     0     0     0  4006  1404
    0    26    64     -     6     0     0     0  4006  1404
    0    26    64     -     0     0     0     0  4006  1404
    0     3    63     -     0     0     0     0   405   139
    0     3    62     -    25     4     0     0   405   139
    0     3    62     -     0     0     0     0   405   139
    0     7    61     -    70    15     0     0   405   139
    0     7    61     -   100    12     0     0   405   139
    0     6    60     -   100    14     0     0   405   139
    0     7    60     -   100    10     0     0   405   139
    0     6    59     -   100     6     0     0   405   139
    0     6    59     -   100    11     0     0   405   139
    0     6    58     -    23     5     0     0   405   139
    0     3    58     -     0     0     0     0   405   139
    0     3    57     -     0     0     0     0   405   139
    0     3    57     -    26     5     0     0   405   139
    0     3    57     -     0     0     0     0   405   139
    0     3    56     -     0     0     0     0   405   139
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     6     0     0     0  4006  1404
    0    26    57     -     0     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     6     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     6     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     6     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404
    0    25    57     -     0     0     0     0  4006  1404

I've swapped between modes 1 - 4 like so:

# echo 1 > /sys/devices/platform/MSHW0107:00/perf_mode
# echo 2 > /sys/devices/platform/MSHW0107:00/perf_mode
# echo 3 > /sys/devices/platform/MSHW0107:00/perf_mode
# echo 4 > /sys/devices/platform/MSHW0107:00/perf_mode

The fan will speed up and cool off the GPU, but the wattage is still hosed. Is this some power saving mechanism throttling the dgpu?

@qzed
Copy link
Collaborator

@qzed qzed commented Jul 25, 2019

Is this some power saving mechanism throttling the dgpu?

Very likely, there's also a discussion about this in linux-surface/surface-aggregator-module#18. I don't have any idea yet how to change this or even what exactly is responsible for the limitation.

@protosam
Copy link

@protosam protosam commented Jul 25, 2019

@qzed thanks for replying back. I'll pop over to that discussion and see what I can do to help out. I might have some basic lack of knowledge questions, so forgive me for that. I come from more of a sysad/devops background and still have some learning to do in the kernel dev realm.

@qzed
Copy link
Collaborator

@qzed qzed commented Jul 25, 2019

Feel free to ask. Unfortunately I'm not that well versed on the GPU front either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants