Intel CPU Undervolting


12 posts in this topic Last Reply

Recommended Posts

Beware!

Undervolting can cause system crashs and this could cause data loss! Use it on your own risk!

 

Undervolting

Undervolting reduces the power usage of your CPU. Depending on the CPU and used settings 5 to 10W on full load and 0 to 1W in idle.

 

ImportantAt first you should stop your array to avoid data loss (and to avoid parity check on reboot)!

 

Requirements (install them through NerdPack)

- Python 3

- pip

- setuptools

 

Execute the following script by CA User Scripts (do not schedule it, until you did not stress test your setting!):

#!/bin/bash
# #####################################
# Script:      Intel Undervolting v0.3
# Description: Undervolts your Intel CPU
# Author:      Marc Gutt
# 
# Changelog:
# 0.3
# - changed undervolt installation method
# 0.2
# - bug fix
# - unraid notification added
# - more log output
# 0.1
# - first release
# 
# ######### Settings ##################
notification=1
# #####################################
# 
# ######### Script ####################
# make script race condition safe
if [[ -d "/tmp/${0///}" ]] || ! mkdir "/tmp/${0///}"; then exit 1; fi; trap 'rmdir "/tmp/${0///}"' EXIT;
# Check if python3 is installed (can be installed through NerdPack)

# check if Python 3 is installed
if [[ "$(python3 -V)" =~ "command not found" ]]; then
    /usr/local/emhttp/webGui/scripts/notify -i alert -s "CPU Undervolting failed!" -d "Python 3 is missing!"
fi

# check if pip is installed
if [[ "$(pip -V)" =~ "command not found" ]]; then
    /usr/local/emhttp/webGui/scripts/notify -i alert -s "CPU Undervolting failed!" -d "pip (Python package manager) is missing!"
    exit 1
fi

# check if setuptools is installed
if [[ ! "$(pip list)" =~ "setuptools" ]]; then
    /usr/local/emhttp/webGui/scripts/notify -i alert -s "CPU Undervolting failed!" -d "setuptools (Python package library) is missing!"
    exit 1
fi

# Check and install undervolt
if [[ ! "$(undervolt --version)" =~ "undervolt" ]]; then
    echo "Undervolt is missing and will be installed..."
    pip install undervolt
fi

# Get CPU Model
cpu_model=$(lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1')
echo $cpu_model

# Undervolt CPU
undervolt --gpu -50 --core -50 --cache -50 --uncore -50 --analogio -50
undervolt --read
undervolt_read=$(undervolt --read | tr '\n' ' ')
if [[ $notification == "1" ]]; then
    /usr/local/emhttp/webGui/scripts/notify -i normal -s "CPU undervolted" -d "$undervolt_read"
fi

-50mV should work with all CPUs, but I suggest to stop the array first, install stress and perform it as described in the next section, before using the undervolted CPU on your productive server. Other often used variants as an example:

undervolt --gpu -75 --core -100 --cache -100 --uncore -100 --analogio -100
undervolt --gpu -50 --core -130 --cache -100 --uncore -130 --analogio -100

Feel free to post your CPU model and used command.

 

Stress

After setting the undervolting (you hopefully stopped your array, if not, do it!), you can now install stress as follows:

wget https://packages.slackonly.com/pub/packages/14.2-x86_64/system/stress/stress-1.0.4-x86_64-1_slonly.txz -P /tmp
upgradepkg --install-new /tmp/stress-1.0.4-x86_64-1_slonly.txz

And execute it as follows if your CPU has 4 cores (change the value as needed):

stress --cpu 4

 

Edited by mgutt
Link to post

thank you much but i have some problems with script:

 

/tmp/user.scripts/tmpScripts/undervolt script/script: line 8: syntax error near unexpected token `fi'
/tmp/user.scripts/tmpScripts/undervolt script/script: line 8: `    fi'

Link to post

I had the same issue with the script to but I got it to run by editing it.

 

#!/bin/bash

# Check if python3 is installed (can be installed through NerdPack)
if [[ "$(python3 -V)" =~ "Python 3" ]]; 
then
    # Check if undervolt is already installed
    [[ ! "$(undervolt --version)" =~ "undervolt" ]];
        wget http://slackware.cs.utah.edu/pub/slackware/slackware64-current/slackware64/ap/undervolt-20200612_07d0c70-x86_64-1.txz -P /tmp
        upgradepkg --install-new /tmp/undervolt-20200612_07d0c70-x86_64-1.txz
    fi
    # Undervolt CPU
    undervolt --gpu -75 --core -100 --cache -100 --uncore -100 --analogio -100
    undervolt --read

But I run into another issue.

 

Resolving slackware.cs.utah.edu (slackware.cs.utah.edu)... 155.98.64.87
Connecting to slackware.cs.utah.edu (slackware.cs.utah.edu)|155.98.64.87|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14936 (15K) [text/plain]
Saving to: '/tmp/undervolt-20200612_07d0c70-x86_64-1.txz.1'

0K .......... .... 100% 13.2K=1.1s

2020-10-21 17:10:06 (13.2 KB/s) - '/tmp/undervolt-20200612_07d0c70-x86_64-1.txz.1' saved [14936/14936]


+==============================================================================
| Skipping package undervolt-20200612_07d0c70-x86_64-1 (already installed)
+==============================================================================

Traceback (most recent call last):
File "/usr/bin/undervolt", line 33, in
sys.exit(load_entry_point('undervolt==0.3.0', 'console_scripts', 'undervolt')())
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 411, in main
set_offset(plane, offset, msr)
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 222, in set_offset
write_msr(write_value, msr.addr_voltage_offsets)
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 81, in write_msr
os.write(f, pack('Q', val))
OSError: [Errno 5] Input/output error
temperature target: -0 (100C)
Traceback (most recent call last):
File "/usr/bin/undervolt", line 33, in
sys.exit(load_entry_point('undervolt==0.3.0', 'console_scripts', 'undervolt')())
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 455, in main
voltage = read_offset(plane, msr)
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 208, in read_offset
write_msr(value_to_write, msr.addr_voltage_offsets)
File "/usr/lib64/python3.8/site-packages/undervolt.py", line 81, in write_msr
os.write(f, pack('Q', val))
OSError: [Errno 5] Input/output error
Script Finished Oct 21, 2020 17:10.06

 

Link to post

v0.3 released:

- changed undervolt installation method

 

Now undervolt is not installed by URL, instead its installed through the pip/setuptools package management, which is the recommened method to install python packages.

Link to post
  • 1 month later...
  • 1 month later...
Script location: /tmp/user.scripts/tmpScripts/Undervolt/script
Note that closing this window will abort the execution of this script
/tmp/user.scripts/tmpScripts/Undervolt/script: line 44: undervolt: command not found
Undervolt is missing and will be installed...
Collecting undervolt
Downloading undervolt-0.3.0.tar.gz (10 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hdj944q9/undervolt/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hdj944q9/undervolt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-hdd0073d
cwd: /tmp/pip-install-hdj944q9/undervolt/
Complete output (11 lines):
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python3.9/site-packages/setuptools/__init__.py", line 18, in
from setuptools.dist import Distribution
File "/usr/lib64/python3.9/site-packages/setuptools/dist.py", line 32, in
from setuptools import windows_support
File "/usr/lib64/python3.9/site-packages/setuptools/windows_support.py", line 2, in
import ctypes
File "/usr/lib64/python3.9/ctypes/__init__.py", line 8, in
from _ctypes import Union, Structure, Array
ImportError: libffi.so.7: cannot open shared object file: No such file or directory
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
/tmp/user.scripts/tmpScripts/Undervolt/script: line 54: undervolt: command not found
/tmp/user.scripts/tmpScripts/Undervolt/script: line 55: undervolt: command not found
/tmp/user.scripts/tmpScripts/Undervolt/script: line 56: undervolt: command not found

got this error.

Link to post

@PCR

Try to install the slackware package of undervolt instead:

wget http://slackware.cs.utah.edu/pub/slackware/slackware64-current/slackware64/ap/undervolt-20201024_13fa33d-x86_64-1.txz -N -P /tmp
upgradepkg --install-new /tmp/undervolt-20201024_13fa33d-x86_64-1.txz

Does this work for you?

Link to post
cript location: /tmp/user.scripts/tmpScripts/Undervolt/script
Note that closing this window will abort the execution of this script
Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
temperature target: -0 (100C)
core: -49.8 mV
gpu: -49.8 mV
cache: -49.8 mV
uncore: -49.8 mV
analogio: -49.8 mV
powerlimit: 130.0W (short: 0.00244140625s - enabled) / 115.0W (long: 16.0s - enabled)

yes. but why? have i made a mistake?

 

Best

Link to post
On 1/11/2021 at 7:15 PM, PCR said:

have i made a mistake?

No, must be something regarding the pip package I think. I will change my script so it does not use it anymore.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.