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

set power_limit AssertionError #12

Open
LinusChen-yf opened this issue Jul 6, 2022 · 2 comments
Open

set power_limit AssertionError #12

LinusChen-yf opened this issue Jul 6, 2022 · 2 comments

Comments

@LinusChen-yf
Copy link

~ sudo throttlestop tdp 1 err | 14:30:42

{
    "MSR_PKG_POWER_LIMIT": 18722037335687528,
    "first": {
        "MSR_PKG_POWER_LIMIT": 18722037335687528,
        "power_limit": 45.0,
        "power_enabled": true,
        "power_clamping_limit": true,
        "power_limit_time_window": 28.0,
        "__types.SimpleNamespace": true
    },
    "second": {
        "MSR_PKG_POWER_LIMIT": 4359064,
        "power_limit": 115.0,
        "power_enabled": true,
        "power_clamping_limit": false,
        "power_limit_time_window": 0.00244140625,
        "__types.SimpleNamespace": true
    },
    "lock": false,
    "__types.SimpleNamespace": true
}

~ sudo throttlestop tdp "{"first": {"power_limit": 65.0}}" ok | 14:30:50

Traceback (most recent call last):
  File "/usr/bin/throttlestop", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/throttlestop/__main__.py", line 53, in main
    result = build_MSR_PKG_POWER_LIMIT(power_limits, units)
  File "/usr/lib/python3.10/site-packages/throttlestop/msr.py", line 96, in build_MSR_PKG_POWER_LIMIT
    result = _build_MSR_PKG_POWER_LIMIT_internal(_obj.first, _units, _max_power_limit)
  File "/usr/lib/python3.10/site-packages/throttlestop/msr.py", line 107, in _build_MSR_PKG_POWER_LIMIT_internal
    assert 0. <= _obj.power_limit <= _max_power_limit, _obj.power_limit
AssertionError: 65.0

I don't quite understand why this assertion fails, my cpu max tdp is 115w.
Hope you can help me look at this problem in your busy schedule, thanks in advance!

@azidanit
Copy link

azidanit commented Jul 8, 2023

after reading the code at /usr/lib/python3.10/site-packages/throttlestop/msr.py line 94.
I changed the from _max_power_limit=60 to _max_power_limit=90 make sure to know you processor TDP

def build_MSR_PKG_POWER_LIMIT(_obj, _units, _max_power_limit=60):
    assert isinstance(_obj.lock, bool)
    result = _build_MSR_PKG_POWER_LIMIT_internal(_obj.first, _units, _max_power_limit)
    result |= _build_MSR_PKG_POWER_LIMIT_internal(_obj.second, _units, _max_power_limit) << 32
    result |= int(_obj.lock) << 63
    return result

you can use nano or vim to change the file

@LinusChen-yf
Copy link
Author

I see why, thank you.
I shouldn't have looked at the code carefully at that time.

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

No branches or pull requests

2 participants