The Raspberry Pi 4 has a 1.5 GHz processor. That means the CPU can update 1.5 Billion times a second. But… it technically can go a little faster than that. This is called overclocking because the “clock” is an electronic pulse used to coordinate processes. The faster that “clock” runs, the more processing you can do. Of course, there is a limit.
Measuring Current Speeds
First off, I wanted a way to measure the processor speed. While the default max is 1.5 GHz. You can do that with this command:
sudo watch -n 1 vcgencmd measure_clock arm
The output will be something like:
This is showing that the pi is idling at 600 MHz (0.6 GHz). If you were to then start a command (
stockfish bench) you would see that number go up to the max of 1.5 GHz.
Changing the Values
To overclock, you need to edit this file:
sudo vi /boot/config.txt
Look for the line that says:
#uncomment to overclock the arm. 700 MHz is the default.
First off, 700 MHz is no longer the default. I wonder if that was left over from early version of the raspberry pi. The current default is actually 1500 MHz (1.5 GHz).
While there is only one line commented out, there are actually 2 settings to change here. Here is what I ended up with after some trial and error:
#uncomment to overclock the arm. 700 MHz is the default. over_voltage=3 arm_freq=1875
I picked 1875 MHz because it was a 25% increase over the default 1500 MHz. The
over_voltage setting I do not really understand other than the faster speeds need more power to run and this tells it to use more energy.
Recovering from Failures
I tried a few things that ended up not working. 2000 MHz (over_voltage=6) as recommended in the article at the bottom. This worked but my stockfish cluster would regularly disconnect. I also tried 2000 MHz (over_voltage=2) and ran in to more serious problems. In this case, the raspberry pi would not even start.
If you encounter this, take the SD card out of you Raspberry Pi and put it in a different computer (like a laptop). Then you will be able to edit the
/boot/config.txt file directly. Set the overclocking settings back to a value that works, eject the SD card, put it back into your pi, and it should start up.
I was not sure what to expect with the overclocking. To my delight, when I ran the stockfish benchmarks the results were just over 25% faster when I increased the clock speed by 25%. Excellent!
I did also try changing the GPU memory, but that did not have much impact on performance of the Stockfish engine. I think that is because Stockfish does not use GPU processing. Other engines do use GPU so may see some benefit from that.
raspi-config > Performance Options > GPU Memory