Thank you everyone for all the great input.
Yes, cpulimit did the trick.
Plus this bash script from the Ubuntu form:
https://ubuntuforums.org/showthread.php?t=992706
I changed CPU_LIMIT=20 to CPU_LIMIT=50
Created a basic service file: /etc/systemd/system/cpulimit_daemon.service
The script limits all running processes but this is okay since the folding laptop is dedicated to, well... folding.
However, there is a:
BLACK_PROCESSES_LIST=
option if you want to target a specific process such as:
/var/lib/fahclient/cores/cores.foldingathome.org/lin/64bit-sse2/a8-0.0.12/Core_a8.fah/FahCore_a8
Finally, I set Folding Power to Full.
Now my folding laptop is tucked away, folding to its heart's content.
Headless Linux Box
Moderators: Site Moderators, FAHC Science Team
-
- Posts: 28
- Joined: Sun Sep 12, 2021 9:28 pm
- Hardware configuration: OS: Ubuntu 24.04 LTS x86_64
Host: Toshiba Satellite U400
Kernel: 6.8.0-39-generic
Shell: bash 5.2.21
CPU: Intel Core 2 Duo T8300
GPU: Intel Mobile GM965/GL960
Memory: 346MiB / 1958MiB - Location: Cairns, Qld. Australia
- Contact:
Re: Headless Linux Box
2022/08/05 Note: FAHclient version 7.6.21 has cpu limiting ability and is much easier to implement then configuring CGroups.
FAHControl --> Configure --> Slots --> Folding Slots --> select cpu --> select Edit --> select Add
Name: cpu-usage
Value: 45 (or whatever percentage you perfer)
Select OK --> OK --> Save
Restart FAHClient:
sudo service FAHClient restart
======================================================================
Okay, some time has passed while I have been sorting out my headless FAH laptop.
The laptop has been running for the past 9 days without issue.
I have fahclient limited to around 37% of the CPU cores. Core temperatures hangs around 49C.
My first attempt at CPU limiting fahclient using cpulimit did not work out so well.
In order to maintain the CPU limit, cpulimit cycles the fahclient process between run and sleep states, which caused the CPU cores to fluctuate between 30% and 75%.
Way too unstable!
Running top (htop) showed the fahclient CPU process fluctuating all over the place (like a small boat in a big sea). Not good.
Some more research lead me to the linux Control Groups or CGroups which is part of the linux kernel.
This turned out to be a more stable approach to limiting fahclient cpu usage.
Though it is a little more involved then cpulimit to set-up. Here we go.
First install cgroup-tools:
sudo apt install cgroup-tools
Copy example file cgred.conf to /etc/:
sudo cp /usr/share/doc/cgroup-tools/examples/cgred.conf /etc/.
Create cgconfig.conf and cgrules.conf files in /etc/:
sudo vi /etc/cgconfig.conf
group folding {
cpu {
cpu.cfs_quota_us = 70000;
}
}
sudo vi /etc/cgrules.conf
#cgrules.conf
#user:process subsystems group
*:FahCore_a8 cpu folding
Create cgconfigparser.service and cgrulesgend.service files in /etc/systemd/system/:
sudo vi /etc/systemd/system/cgconfigparser.service
[Unit]
Description=cgroup config parser
After=network.target
[Service]
User=root
Group=root
ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf
Type=oneshot
[Install]
WantedBy=multi-user.target
sudo vi /etc/systemd/system/cgrulesgend.service
[Unit]
Description=cgroup rules generator
After=network.target cgconfigparser.service
[Service]
User=root
Group=root
Type=forking
EnvironmentFile=-/etc/cgred.conf
ExecStart=/usr/sbin/cgrulesengd
Restart=on-failure
[Install]
WantedBy=multi-user.target
Initiate and start services:
sudo systemctl daemon-reload
sudo systemctl enable cgconfigparser
sudo systemctl enable cgrulesgend
sudo systemctl start cgconfigparser
sudo systemctl start cgrulesgend
Now when I run top (htop) the fahclient process remains running at around a steady 68% and the CPU cores at around a steady 37%.
I control the fahclient from my Windows PC using FAHControl. Folding Power slider set to Full.
Power off the laptop screen
=======================
This one took awhile to figure out. Blanking the laptop screen is not the same as turning it off.
Blanking the screen simply clear the video image but leaves the screen powered on.
To save power its best to turn the laptop screen off. Here is how its done:
vi screen-off
#!/bin/bash
#
# This script requires sudo.
# check if user is root.
test="`id -u`"
if [[ "$test" != "0" ]] ; then
echo
echo Run this script using sudo
echo sudo screen-off
echo
exit
fi
mount -o remount,exec /dev
vbetool dpms off
mount -o remount,noexec /dev
vi screen-on
#!/bin/bash
#
# This script requires sudo.
# check if user is root.
test="`id -u`"
if [[ "$test" != "0" ]] ; then
echo
echo Run this script using sudo
echo sudo screen-on
echo
exit
fi
mount -o remount,exec /dev
vbetool dpms on
mount -o remount,noexec /dev
Make these bash scripts executable:
chmod +x screen-off
chmod +x screen-on
The laptop screen can be turned on or off from a remote ssh terminal session. The scripts require sudo to run (sudo screen-off)
It can also be set-up to turn off the screen automatically after starting up the laptop.
Create a screen off service:
sudo vi/etc/systemd/system/screen-off.service
[Unit]
Description=Turn screen off after 60 seconds.
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=sleep 60
ExecStart=/<path to script>/screen-off
[Install]
WantedBy=multi-user.target
Initiate and start the service:
sudo systemctl daemon-reload
sudo systemctl enable screen-off.service
sudo systemctl start screen-off.service
That is it. My laptop is happily folding away 24/7 without generating too much heat while consuming less energy.
FAHControl --> Configure --> Slots --> Folding Slots --> select cpu --> select Edit --> select Add
Name: cpu-usage
Value: 45 (or whatever percentage you perfer)
Select OK --> OK --> Save
Restart FAHClient:
sudo service FAHClient restart
======================================================================
Okay, some time has passed while I have been sorting out my headless FAH laptop.
The laptop has been running for the past 9 days without issue.
I have fahclient limited to around 37% of the CPU cores. Core temperatures hangs around 49C.
My first attempt at CPU limiting fahclient using cpulimit did not work out so well.
In order to maintain the CPU limit, cpulimit cycles the fahclient process between run and sleep states, which caused the CPU cores to fluctuate between 30% and 75%.
Way too unstable!
Running top (htop) showed the fahclient CPU process fluctuating all over the place (like a small boat in a big sea). Not good.
Some more research lead me to the linux Control Groups or CGroups which is part of the linux kernel.
This turned out to be a more stable approach to limiting fahclient cpu usage.
Though it is a little more involved then cpulimit to set-up. Here we go.
First install cgroup-tools:
sudo apt install cgroup-tools
Copy example file cgred.conf to /etc/:
sudo cp /usr/share/doc/cgroup-tools/examples/cgred.conf /etc/.
Create cgconfig.conf and cgrules.conf files in /etc/:
sudo vi /etc/cgconfig.conf
group folding {
cpu {
cpu.cfs_quota_us = 70000;
}
}
sudo vi /etc/cgrules.conf
#cgrules.conf
#user:process subsystems group
*:FahCore_a8 cpu folding
Create cgconfigparser.service and cgrulesgend.service files in /etc/systemd/system/:
sudo vi /etc/systemd/system/cgconfigparser.service
[Unit]
Description=cgroup config parser
After=network.target
[Service]
User=root
Group=root
ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf
Type=oneshot
[Install]
WantedBy=multi-user.target
sudo vi /etc/systemd/system/cgrulesgend.service
[Unit]
Description=cgroup rules generator
After=network.target cgconfigparser.service
[Service]
User=root
Group=root
Type=forking
EnvironmentFile=-/etc/cgred.conf
ExecStart=/usr/sbin/cgrulesengd
Restart=on-failure
[Install]
WantedBy=multi-user.target
Initiate and start services:
sudo systemctl daemon-reload
sudo systemctl enable cgconfigparser
sudo systemctl enable cgrulesgend
sudo systemctl start cgconfigparser
sudo systemctl start cgrulesgend
Now when I run top (htop) the fahclient process remains running at around a steady 68% and the CPU cores at around a steady 37%.
I control the fahclient from my Windows PC using FAHControl. Folding Power slider set to Full.
Power off the laptop screen
=======================
This one took awhile to figure out. Blanking the laptop screen is not the same as turning it off.
Blanking the screen simply clear the video image but leaves the screen powered on.
To save power its best to turn the laptop screen off. Here is how its done:
vi screen-off
#!/bin/bash
#
# This script requires sudo.
# check if user is root.
test="`id -u`"
if [[ "$test" != "0" ]] ; then
echo
echo Run this script using sudo
echo sudo screen-off
echo
exit
fi
mount -o remount,exec /dev
vbetool dpms off
mount -o remount,noexec /dev
vi screen-on
#!/bin/bash
#
# This script requires sudo.
# check if user is root.
test="`id -u`"
if [[ "$test" != "0" ]] ; then
echo
echo Run this script using sudo
echo sudo screen-on
echo
exit
fi
mount -o remount,exec /dev
vbetool dpms on
mount -o remount,noexec /dev
Make these bash scripts executable:
chmod +x screen-off
chmod +x screen-on
The laptop screen can be turned on or off from a remote ssh terminal session. The scripts require sudo to run (sudo screen-off)
It can also be set-up to turn off the screen automatically after starting up the laptop.
Create a screen off service:
sudo vi/etc/systemd/system/screen-off.service
[Unit]
Description=Turn screen off after 60 seconds.
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=sleep 60
ExecStart=/<path to script>/screen-off
[Install]
WantedBy=multi-user.target
Initiate and start the service:
sudo systemctl daemon-reload
sudo systemctl enable screen-off.service
sudo systemctl start screen-off.service
That is it. My laptop is happily folding away 24/7 without generating too much heat while consuming less energy.
-
- Posts: 1
- Joined: Fri Mar 29, 2024 1:00 am
Re: Headless Linux Box
Thanks for this note! Running 7.6.21 on Ubuntu 22.04 and managing with FAHControl on Windows 10, it's not necessary to restart the service every time I've made changes to 'cpu-usage' option. The watt-o-meter on the wall plug shows the change on the fly. That helps to keep a convenient energy consumption for me.DoctorBob wrote: ↑Tue Oct 12, 2021 2:20 am 2022/08/05 Note: FAHclient version 7.6.21 has cpu limiting ability and is much easier to implement then configuring CGroups.
FAHControl --> Configure --> Slots --> Folding Slots --> select cpu --> select Edit --> select Add
Name: cpu-usage
Value: 45 (or whatever percentage you perfer)
Select OK --> OK --> Save
Restart FAHClient:
sudo service FAHClient restart
...
Xeon E3-1275L v3 (1 thread @ 10%) running Ubuntu 22.04 VM over TrueNAS Core
-
- Site Admin
- Posts: 7922
- Joined: Tue Apr 21, 2009 4:41 pm
- Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2 - Location: W. MA
Re: Headless Linux Box
One thing that was not pointed out when this approach was mentioned back in 2021 is that the cpu-usage option is a legacy holdover from a decade ago. It was only supported by the folding cores that used a single processor for calculations. With the cores meant for multi-threaded processing it only limits CPU usage on one thread. That can result in a greater than expected change in processing speed when processing on that thread is out of synch with the other threads. Exact effects will depend a bit on the thread scheduler in the OS.
iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3