Controlling the fan speed of an AMD Radeon R7 260X GPU on Ubuntu can be achieved using the amdgpu driver -- the open-source driver for AMD GPUs, or the proprietary amdgpu-pro driver available from AMD. Both drivers offer support for fan control, but the process is typically done via command line utilities or configuration files.
Step 1: Ensure Correct Driver Installation
First, verify whether you're using the open-source amdgpu driver or the proprietary amdgpu-pro driver.
For the Open-Source amdgpu Driver
This driver is typically bundled with the Linux kernel, so you generally don't need to install it separately. Ensure it is being used with:
lsmod | grep amdgpu
For the Proprietary amdgpu-pro Driver
Download and install the amdgpu-pro driver from the official AMD website following their instructions.
Step 2: Install Required Tools
Regardless of which driver you use, you will typically need lm-sensors and other tools to monitor and control your hardware.
sudo apt update
sudo apt install lm-sensors
sudo apt install xsensors
Step 3: Enable Sensor Modules
Run the sensors detection tool to find available sensors:
sudo sensors-detect
Follow the prompts and accept the default answers.
Step 4: Control the Fan Speed Using amdgpu Driver
Using aticonfig (AMD Command Line Tool)
For older drivers or the proprietary driver, you might have aticonfig (now often referred to as amdconfig):
sudo amdconfig --pplib-cmd "set fanspeed 0 50"
In this command, 0 is the fan index, and 50 is the desired fan speed percentage.
Using Direct Sysfs Access
With newer amdgpu drivers, you might be able to control the fan speed directly through the /sys/class/drm directory.
-
First, find the exact path to your GPU:
ls /sys/class/drm/
It usually shows entries like card0 or card1. Identify which card is your R7 260X.
-
Check current fan speed:
cat /sys/class/drm/card0/device/hwmon/hwmon0/pwm1
This assumes your card corresponds to card0 and hwmon0 (these might differ, adjust accordingly).
-
Set the fan speed:
First, you may need to set the fan control to manual mode:
echo 1 | sudo tee /sys/class/drm/card0/device/hwmon/hwmon0/pwm1_enable
Then set the desired fan speed:
echo 128 | sudo tee /sys/class/drm/card0/device/hwmon/hwmon0/pwm1
In this example, 128 is half of the maximum value (which is 255), so it sets the fan speed to 50%.
GUI Tools
While the command line is powerful, GUI tools like Psensor can also help, but they might not provide fan control features directly. You can install it with:
sudo apt install psensor
Launch Psensor to monitor your GPU temperatures and fans.
Script Automation
You could also create a script to automate fan control based on temperature. Here’s an example script:
#!/bin/bash
# GPU fan speed control script
GPU_PATH="/sys/class/drm/card0/device/hwmon/hwmon0"
FAN_SPEED=128 # Set fan speed (0-255)
TEMP_THRESHOLD=60 # Temperature in Celsius
while true; do
CURRENT_TEMP=$(cat $GPU_PATH/temp1_input)
CURRENT_TEMP=$(($CURRENT_TEMP/1000)) # Convert from millidegrees
if [[ $CURRENT_TEMP -gt $TEMP_THRESHOLD ]]; then
echo 1 | sudo tee $GPU_PATH/pwm1_enable
echo $FAN_SPEED | sudo tee $GPU_PATH/pwm1
else
echo 0 | sudo tee $GPU_PATH/pwm1_enable
fi
sleep 5 # Check every 5 seconds
done
Make it executable and run it:
chmod +x gpu_fan_control.sh
sudo ./gpu_fan_control.sh
This script checks the temperature every 5 seconds and adjusts the fan speed accordingly.
Keep in mind that controlling hardware at this level can have risks, so ensure you understand what each command does to avoid potential damage to your hardware.