{"id":13764981,"url":"https://github.com/sibradzic/amdgpu-clocks","last_synced_at":"2025-05-10T20:31:32.068Z","repository":{"id":47435689,"uuid":"153491644","full_name":"sibradzic/amdgpu-clocks","owner":"sibradzic","description":"Simple script to control power states of amdgpu driven GPUs","archived":false,"fork":false,"pushed_at":"2025-04-07T15:18:39.000Z","size":74,"stargazers_count":425,"open_issues_count":1,"forks_count":46,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-07T16:32:43.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sibradzic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-17T16:47:59.000Z","updated_at":"2025-04-07T15:18:47.000Z","dependencies_parsed_at":"2024-01-30T06:59:49.985Z","dependency_job_id":"26c5b991-aaa4-4d45-838e-9103fade12da","html_url":"https://github.com/sibradzic/amdgpu-clocks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibradzic%2Famdgpu-clocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibradzic%2Famdgpu-clocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibradzic%2Famdgpu-clocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibradzic%2Famdgpu-clocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sibradzic","download_url":"https://codeload.github.com/sibradzic/amdgpu-clocks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480469,"owners_count":21915246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:00:32.301Z","updated_at":"2025-05-10T20:31:27.055Z","avatar_url":"https://github.com/sibradzic.png","language":"Shell","funding_links":[],"categories":["Graphics cards"],"sub_categories":["AMD"],"readme":"## AMDGPU Clocks\n\n### Introduction\n\nThis is a simple script that can be used to set custom power states for recent\nAMD GPUs that are driven by **amdgpu** Linux kernel driver. The script is able\nto set custom clocks, voltages and some other power states, assuming that\nRadeon OverDrive is enabled in kernel boot opions. The OverDrive is not enabled\nby default as of Linux 5.x, it can be enabled by setting 14th bit (0x4000) of a\n**ppfeaturemask** amdgpu driver to 1. For example, setting\n**amdgpu.ppfeaturemask=0xfffd7fff** or **amdgpu.ppfeaturemask=0xffffffff**\nkernel boot option will do the trick. This would enable amdgpu driver sysfs\nAPI that allows fine grain control of GPU power states (GPU \u0026 VRAM clocks \u0026\nvoltages, depending on the actual hardware).\nIt should work on Polaris, Vega (unfortunately Vega found on AMD APUs does\nnot expose this API), Navi and RDNA cards, and it can be used to easily manage\nmultiple AMD graphics cards.\n\n### How does it work\n\nBy default, custom power states for a particular GPU can be defined in\n`/etc/default/amdgpu-custom-state.cardX` file, which is expected to be created\nby user, and where X corresponds to a card in `/sys/class/drm/cardX`. The\ncustom state file have same format as the actual\n`/sys/class/drm/cardX/device/pp_od_clk_voltage`, with option to add\nnewlines, comments (lines starting with `#`) and few additional parameters used\nto set extra power state parameters. These are **FORCE_SCLK** \u0026 **FORCE_MCLK**,\nthat can be used to limit GPU and memory power states to a particular subset\nof states, **FORCE_POWER_CAP** that can be used to set desired power cap,\n**FORCE_PERF_LEVEL** that can be used to force desired\n`power_dpm_force_performance_level` for a card (which can be `auto`, `low`,\n`high`, `manual`, etc) and **FORCE_POWER_PROFILE** used for manually setting\nthe profile found in card's `pp_power_profile_mode`.\n\nSince some Linux kernel versions are known to enumerate the very same card to\na different `cardX` identifier (X randomly toggles between 0 or 1 on reboot),\none can alternatively define the custom state using\n`/etc/default/amdgpu-custom-state.pci:xxxx:xx:xx.x` file instead, where\n`xx:xx.x` corrsponds to intended card's PCI `\u003cdomain\u003e:\u003cbus\u003e:\u003cdev\u003e.\u003cfunction\u003e`\nnumbers. For example `/etc/default/amdgpu-custom-state.pci:0000:03:00.0`.\n\nHere is an example how custom power state file may look like for Polaris cards:\n\n    $ cat /etc/default/amdgpu-custom-states.card0\n    # Set custom GPU states 6 \u0026 7:\n    OD_SCLK:\n    6:       1000MHz        860mV\n    7:       1050MHz        890mV\n    # Set custom memory states 1 \u0026 2:\n    OD_MCLK:\n    1:        900MHz        800mV\n    2:       1600MHz        900mV\n    # Only allow SCLK states 5, 6 \u0026 7:\n    FORCE_SCLK: 5 6 7\n    # Force fixed memory state:\n    FORCE_MCLK: 2\n    # Force power limit (in micro watts):\n    FORCE_POWER_CAP: 90000000\n    # In order to allow FORCE_SCLK \u0026 FORCE_MCLK:\n    FORCE_PERF_LEVEL: manual\n\nHere is an example how custom power state file may look like for Navi cards:\n\n    # For Navi (and Radeon7) we can only set highest SCLK \u0026 MCLK, \"state 1\":\n    OD_SCLK:\n    1: 1550MHz\n    OD_MCLK:\n    1: 750MHz\n    # More fine-grain control of clocks and voltages are done with VDDC curve:\n    OD_VDDC_CURVE:\n    0: 800MHz @ 800mV\n    1: 1125MHz @ 820mV\n    2: 1550MHz @ 850mV\n    # Force power limit (in micro watts):\n    FORCE_POWER_CAP: 87000000\n    FORCE_PERF_LEVEL: manual\n\nHere is an example how custom power state file may look like for RDNA2 cards:\n\n    OD_VDDGFX_OFFSET:\n    -75mV\n    FORCE_PERF_LEVEL: manual\n    FORCE_POWER_CAP: 99000000\n\n### Installing and manually running the script\n\nSimply place the [script](amdgpu-clocks) in `/usr/local/bin/amdgpu-clocks`:\n\n    sudo ln -s $(pwd)/amdgpu-clocks /usr/local/bin/amdgpu-clocks\n\nand specify custom power states in `/etc/default/amdgpu-custom-states.card0`:\n\n    $ sudo amdgpu-clocks\n\n    Detecting the state values at /sys/class/drm/card0/device/pp_od_clk_voltage:\n      SCLK state 0: 700Mhz\n      SCLK state 1: 2539Mhz\n      MCLK state 0: 97Mhz\n      MCLK state 1: 1000MHz\n      VDD GFX Offset: 0mV\n      Maximum clocks \u0026 voltages:\n        SCLK clock 3150Mhz\n        MCLK clock 1200Mhz\n      Curent power cap: 130W\n    Verifying user state values at /etc/default/amdgpu-custom-state.card0:\n      VDD GFX Offset: -75mV\n      Force performance level to manual\n      Force power cap to 99W\n    Committing custom states to /sys/class/drm/card0/device/pp_od_clk_voltage:\n      Done\n\nThe script can also be invoked with specific custom state file prefix (can be\na directory, case trailing slash is supplied), for example:\n\n    $ sudo USER_STATES_PATH=custom-states amdgpu-clocks\n\nThis will load and apply custom states from all `custom-states.card*` files\nin the current directory. Script can also be used with an additional 'restore'\nparameter that can be used to restore all states to the initial defaults\n(states before script was executed for the first time), with exception of\n`pp_power_profile_mode` which will be set to 0.\n\n### Making the custom power states persist\n\nThis can be achieved by placing provided *systemd* service\n[file](amdgpu-clocks.service) in `/etc/systemd/system/` directory,\nand enable it:\n\n    $ sudo systemctl enable --now amdgpu-clocks\n\nHowever, if your system goes to suspend state, the above service will not\nauto-restart (due to RemainAfterExit parameter). To fix that copy provided\n[file](amdgpu-clocks-resume) into `/usr/lib/systemd/system-sleep`\n\n    $ cp amdgpu-clocks-resume /usr/lib/systemd/system-sleep/\n\nOf course, one should not forget to place the actual custom power states in\n`/etc/default/amdgpu-custom-state.cardX`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibradzic%2Famdgpu-clocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsibradzic%2Famdgpu-clocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibradzic%2Famdgpu-clocks/lists"}