|
1 | 1 | # nvidia-offset-controller |
2 | | -Small scripts to control Nvidia GPUs frequency offsets |
| 2 | +Small scripts to control Nvidia GPUs frequency offsets. |
3 | 3 |
|
4 | | -Second edition now uses python. |
5 | | -Requirements: |
6 | | -Driver 555+ |
7 | | -Python 3.12 |
8 | | -nvidia-smi <=565 (only for voltage reading) |
| 4 | +This repository provides tools for monitoring and dynamically adjusting NVIDIA GPU clock offsets to optimize performance and stability, particularly on Linux. |
9 | 5 |
|
10 | | -Basic offset controller with advanced settings. |
| 6 | +## Tools |
11 | 7 |
|
12 | | -Settings explanation: |
| 8 | +### 1. `gpu_offset_control_v2` (Python) |
| 9 | +The primary and most advanced tool in this repository. It dynamically adjusts GPU clock offsets based on temperature, power consumption, and current frequency using the NVIDIA Management Library (NVML). |
13 | 10 |
|
14 | | -nvidia_smi_lgc_min & nvidia_smi_lgc_max -set range GPU frequencies should work (RTX 30xx desktop & mobile (Ampere arch) & up only) |
| 11 | +**Features:** |
| 12 | +- Dynamic offset adjustment based on real-time GPU telemetry. |
| 13 | +- Smart rounding to prevent micro-adjustments and potential stuttering. |
| 14 | +- P-state aware: applies calculated offsets primarily to P0 state, using stable defaults for others. |
| 15 | +- Integrated memory clock offset control. |
15 | 16 |
|
16 | | -frequency_min & frequency_max - set frequencies range for offset calculations |
| 17 | +**Usage:** |
| 18 | +```bash |
| 19 | +sudo python3 gpu_offset_control_v2 |
| 20 | +``` |
17 | 21 |
|
18 | | -freq_offset_min & freq_offset_max - set main offsets to calculate offsets between frequency_min & frequency_max |
| 22 | +### 2. `nvidia_stats.c` (C) |
| 23 | +A utility to read advanced NVIDIA GPU statistics not typically available via `nvidia-smi`, such as Core Voltage, Hotspot Temperature, and Memory Temperature. It utilizes undocumented NVAPI calls. |
19 | 24 |
|
20 | | -temperature_min & temperature_max - set temperatures range for additional offset calculations |
| 25 | +**Compilation:** |
| 26 | +```bash |
| 27 | +gcc -o nvidia_stats nvidia_stats.c -ldl |
| 28 | +``` |
21 | 29 |
|
22 | | -plimit_min & plimit_max - set GPU power consumpion range for additional offset calculations |
| 30 | +**Usage:** |
| 31 | +```bash |
| 32 | +./nvidia_stats |
| 33 | +``` |
23 | 34 |
|
24 | | -low_freq_min, low_freq_max, high_freq_min, high_freq_max - additinal offset, which applied with positive coefficient at low frequencies and negative coefficient at high frequencies, because of transistors characteristics. Controlled by variable drain_offset_control |
| 35 | +### 3. Shell Scripts (Legacy) |
| 36 | +- `nvidia-offset-advanced.sh`: Advanced shell script for frequency and memory offset control using `nvidia-settings`. |
| 37 | +- `nvidia_offset_basic.sh`: A simplified version for basic frequency offset control. |
25 | 38 |
|
26 | | -drain_offset_lmin, drain_offset_lmax, drain_offset_hmin, drain_offset_hmax - offset, which take into account tranfer characteristics of transistors with regions of positive and negative temperature coefficient. Controlled by variable drain_offset_control |
| 39 | +**Usage:** |
| 40 | +```bash |
| 41 | +./nvidia-offset-advanced.sh |
| 42 | +``` |
27 | 43 |
|
28 | | -power_offset_max, power_offset_min - additional offset, which further downvolt GPU core, because GPU core can work with lower voltage when not fully loaded. Controlled by variable power_offset_control |
| 44 | +## Requirements |
| 45 | +- **NVIDIA Driver:** 555+ (Recommended) |
| 46 | +- **Python:** 3.12+ |
| 47 | +- **Python Packages:** `nvidia-ml-py` (required for `gpu_offset_control_v2`) |
| 48 | +- **System Utilities:** |
| 49 | + - `nvidia-smi` (v565 or earlier is required for voltage reading via smi) |
| 50 | + - `nvidia-settings` (required for shell scripts) |
| 51 | +- **Compiler:** `gcc` (required to compile `nvidia_stats.c`) |
29 | 52 |
|
30 | | -critical_range_offset - additional setting to prevent GPU instabilities because of voltage fluctuations in a predefined temperature range by disabling drain offset calculations in that region |
| 53 | +## Settings Explanation |
| 54 | +The scripts use various parameters to calculate the optimal offset. Below is an explanation of the core settings: |
| 55 | + |
| 56 | +- **nvidia_smi_lgc_min & nvidia_smi_lgc_max**: Sets the frequency range within which the GPU is allowed to operate (locked graphics clocks). *Note: Supported on RTX 30xx (Ampere) and newer.* |
| 57 | +- **frequency_min & frequency_max**: The frequency range used for linear offset interpolation. |
| 58 | +- **freq_offset_min & freq_offset_max**: The base frequency offset range applied between `frequency_min` and `frequency_max`. |
| 59 | +- **temperature_min & temperature_max**: The temperature range used for calculating additional "drain" offsets. |
| 60 | +- **plimit_min & plimit_max**: GPU power consumption range for power-based offset calculations. |
| 61 | +- **low_freq_min, low_freq_max / high_freq_min, high_freq_max**: Defines frequency regions where specific "drain" offsets are applied. |
| 62 | +- **drain_offset_lmin, drain_offset_lmax / drain_offset_hmin, drain_offset_hmax**: Offsets that account for the positive/negative temperature coefficients of transistors in different frequency/voltage regions. |
| 63 | +- **power_offset_min, power_offset_max**: Additional offset that further downvolts the GPU core when it is not fully loaded. |
| 64 | +- **critical_temp_min & critical_temp_max**: Defines a temperature range where certain offset calculations (like drain offset) are disabled or fixed to prevent instability due to voltage fluctuations. |
0 commit comments