Skip to content

Instantly share code, notes, and snippets.

@akaszynski
Created June 10, 2020 12:39
Show Gist options
  • Save akaszynski/56d82b23fb2deb284d6a4773538afc5f to your computer and use it in GitHub Desktop.
Save akaszynski/56d82b23fb2deb284d6a4773538afc5f to your computer and use it in GitHub Desktop.
Undervolt Stability Tester
#!/usr/bin/python
"""Iteratively decrease the core and cache voltage offset until system
becomes unstable.
Requires:
- undervolt
start by running
$ sudo modprobe msr
This script must be run as sudo
To genuinely test for stability, have "stress -c" running in the
background with the maximum number of threads.
"""
import time
import undervolt
inc = 2
wait_time = 10*60
core, cache = -100, -100
undervolt.set_offset('core', core)
undervolt.set_offset('cache', cache)
print('Initial voltage offsets: ', core, cache)
print('Incrementing -%f mV' % inc)
print('Waiting %d seconds at each step' % wait_time)
with open('log.txt', 'w') as f:
while True:
txt = '%d, Core %f, Cache %f\n' % (time.time(), core, cache)
f.write(txt); f.flush()
print(txt)
time.sleep(wait_time)
core -= inc
cache -= inc
undervolt.set_offset('core', core)
undervolt.set_offset('cache', cache)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment