Skip to main content

A small program that uses the NVIDIA Management Library to control the GPU independent of OS or display server. This project is not provided or endorsed by NVIDIA

Project description

CaioH NVML GPU Control

This is a small program that uses the NVIDIA Management Library (NVML) to monitor GPU temperature and set fan speed. NVML is being used, because it is OS and display sever agnostic (that means it doesn't depend on X11 or Windows). Another important reason is that the official NVIDIA tool (NVIDIA smi) does not currently support fan control.

Disclaimer

  • This project is NOT endorsed or sponsored by NVIDIA
  • This project is independent and not affiliated to NVIDIA

Supported hardware

  • Any NVIDIA CUDA supported card with a driver higher or equal to version 520

Dependencies

To use it, you must have installed:

  • NVIDIA's proprietary drivers (>= v555)
  • Python 3
  • nvidia-ml-py (NVIDIA's official python bindings)

You will also need admin/root privileges to be able to set anything. Query can be done by unprivileged users however.

Installation

Windows

Install the package with pip running as admin to make it system wide (needed for startup services)

pip install caioh-nvml-gpu-control

Linux

Install the package with pipx running as root, so it can be installed system-wide (needed for startup services).

sudo pipx install --global caioh-nvml-gpu-control

[!WARNING] Files must be writable only to admin/root, otherwise unprivileged programs may escalate provileges with the startup services. If you followed the steps, this should be done already

Uninstall

Windows

Uninstall the package by running pip as admin

pip uninstall caioh-nvml-gpu-control

Linux

Uninstall the package by running pipx command as root

sudo pipx uninstall --global caioh-nvml-gpu-control

How to use

[!NOTE] Some commands require admin/root privileges to run, so run it with something like sudo (Linux) or in an admin prompt (Windows). Services already run with the highest privileges, so there is no need to prefix the command with sudo.

[!TIP] You can start the program with chnvml if the Scripts directory is in the PATH or use python -m caioh_nvml_gpu_control.

  • You must first list all cards that are connected, so you can get the name or UUID
chnvml list
  • Then you can select a target by name
sudo chnvml control -n 'NVIDIA GeForce RTX 4080'
  • Or by UUID
sudo chnvml control -id GPU-00000000-0000-0000-0000-000000000000
  • And the fan speed for each temperature level (requires admin or root)
sudo chnvml control -n 'NVIDIA GeForce RTX 4080' -sp '10:35,20:50,30:50,35:100'
  • You can also set a temperature or a power limit as well (requires admin or root)
sudo chnvml control -n 'NVIDIA GeForce RTX 4080' -sp '10:35,20:50,30:50,35:100' -tl 65 -pl 280
  • You could also use the --dry-run for testing! (no admin or root)
chnvml control -n 'NVIDIA GeForce RTX 4080' -sp '10:35,20:50,30:50,35:100' --dry-run
  • You can also revert to the original fan state by runnig the following command or rebooting the machine
sudo chnvml fan-policy --auto -n 'NVIDIA GeForce RTX 4080'

Note that it does not current support fan curve (or linear progression), so it works on levels. Each level the temperature is verified against the configuration (higher or equal) and then set properly. Also, each temperature associated with speed is ordered automatically. (think of it as a staircase graph)

Temp : speed(%)

1. 40 : 100 (>=40°C - 100%)

2. 30 : 50 (>=30°C - 50%)

3. 20 : 30 (>=20°C - 30%)

4. Default speed (DS)

___________________________

41°C - 100%

21°C - 30%

19°C - Default speed

Usage actions and options

python ./nvml_gpu_control.py <ACTION> <OPTIONS>

ACTIONS
    help
          Display help text

    list
          List all available GPUs connected to the system by printing its name and UUID

    control
         Allows the use of all controls in a single command/loop. Each setting is enabled by configuring its respective option: fan curve, power and temperature

    fan-info
          Shows information about fan speed

    fan-policy <--auto|--manual>
          Changes the fan control policy to automatic (vBIOS controlled) or manual. Note that when the fan speed is changed, the NVML library automatically changes this setting to manual. This setting is useful to change the GPU back to its original state

    fan-policy-info
          Shows information about the current fan policy

    power-limit-info
          Shows information about the power limit of the selected GPU

    thresholds-info
          Shows information about temperature thresholds in dregrees Celsius of the selected GPU.

OPTIONS

    --name OR -n <GPU_NAME>
          Select a target GPU by its name. Example: --name "NVIDIA GeForce RTX 4080". Note: UUID has preference over name

    --uuid OR -id <GPU_UUID>
          Select a target GPU by its Universally Unique IDentifier (UUID). Example: --uuid "GPU-00000000-0000-0000-0000-000000000000". Note: UUID has preference over name

    --time-interval OR -ti <TIME_SECONDS>
          Time period in seconds to wait before probing the GPU again. Works for all actions that run in a loop

    --retry-interval OR -ri <TIME_SECONDS>
          Time period in seconds to wait before trying to issue commands to the GPU again. Works for all actions that run in a loop

    --dry-run OR -dr
          Run the program, but don't change/set anything. Useful for testing the behavior of the program

    --speed-pair OR -sp <TEMP_CELSIUS:SPEED_PERCENTAGE,TEMP_CELSIUS:SPEED_PERCENTAGE...>
          A comma separated list of pairs of temperature in celsius and the fan speed in % (temp:speed) defining basic settings for a fan curve

    --default-speed OR -ds <FAN_SPEED_PERCENTAGE>
          Set a default speed for when there is no match for the fan curve settings

    --manual
          Sets the fan policy to manual

    --auto
          Sets the fan policy to automatic (vBIOS controlled)

    --power-limit OR -pl <POWER_LIMIT_WATTS>
          Sets the power limit of the GPU in watts

    --acoustic-temp-limit OR -tl <TEMPERATURE_CELSIUS>
          Sets the acoustic threshold in celsious (note that this is the same temperature limit used by GeForce Experience)

    --single-use OR -su
          Makes some actions work only once instead of in a loop

    --verbose OR -V
          When there are no settings changes, leg messages are omitted by default. This option enables them back (good for debugging)

    --retry OR -rt
          By default the program closes when it encounters an error, but this lets the program try to recover. It could be useful to let the service manager restart the process

Changelog

1.0.0.0

  • Initial pypi release

1.1.0.0

  • Added a new option: --verbose OR -V

2.0.0.0

  • Actions removed: fan-control, power-control, temp-control

  • Action renamed: control-all -> control

  • Quality of life

    • More information on initial log
    • Some options aren't automatically ignored anymore

2.1.0.0

  • Added a new option: --retry OR -rt

  • The program now halts by default when it encounters an error, allowing the service manager to restart the process

2.1.1.1

  • NVML dependency update: 12.570.86 -> 13.580.65

  • It now reports the NVML version as well

2.1.2.1

  • Temperature thresholds are now removed from initial information logs (it returns NOT_SUPPORTED on Linux 575.64.05, which caused all controls to fail)

  • It now reports the version of the program

2.1.3.1

  • Control action now uses a separate worker process so it can better recover from failures (useful for retries)

2.1.4.1

  • Changed the required minimum driver version (nvmlDeviceGetTemperature was deprecated in favor of the newer function nvmlDeviceGetTemperatureV)
  • Fixed an error with f-string that can cause errors in some versions of python (see GitHub PR)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caioh_nvml_gpu_control-2.1.4.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caioh_nvml_gpu_control-2.1.4.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file caioh_nvml_gpu_control-2.1.4.1.tar.gz.

File metadata

  • Download URL: caioh_nvml_gpu_control-2.1.4.1.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for caioh_nvml_gpu_control-2.1.4.1.tar.gz
Algorithm Hash digest
SHA256 498001305fc0b4c350b575b8626be31468096beb8c4ef51ca22a54b7bcaefd34
MD5 96fde7825441e32252a18f7dd3939c22
BLAKE2b-256 72412b3e63bd4e656b526a7c0f581dbbc1eb7c57c5d283b0cab70b587f9f3437

See more details on using hashes here.

File details

Details for the file caioh_nvml_gpu_control-2.1.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for caioh_nvml_gpu_control-2.1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8cb3f3e908d59631c30c330bcc63d9b7a101a2e87179c4cd9460379ff866e05
MD5 41ed66e8dbeb286144a3ebfce43bc550
BLAKE2b-256 7a4226392a5b9afa11cfc96828184c2f88470b5aecc3d346f7e418bba8c1b2f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page