ROCm / ROC-smi

ROC System Management Interface
https://github.com/RadeonOpenCompute/ROC-smi/blob/master/README.md
178 stars 55 forks source link

Setting custom profile through rocm-smi #57

Closed sabbaghm closed 5 years ago

sabbaghm commented 5 years ago

How exactly we can define and set a custom power profile for an RX 580 (polaris) GPU through rocm-smi ?

When I try: rocm-smi --setprofile 6

I receive the following error: ======================== ROCm System Management Interface ======================== Unable to write to sysfs file /sys/class/drm/card0/device/pp_power_profile_mode GPU[0] : Unable to set CUSTOM Power Profile values WARNING: One or more commands failed ======================== End of ROCm SMI Log ========================

rocm-smi --showprofile prints:

========================        ROCm System Management Interface        ========================
================================================================================================
GPU[0]      : 
GPU[0]      : NUM        MODE_NAME     SCLK_UP_HYST   SCLK_DOWN_HYST SCLK_ACTIVE_LEVEL     MCLK_UP_HYST   MCLK_DOWN_HYST MCLK_ACTIVE_LEVEL
GPU[0]      :   0   BOOTUP_DEFAULT:        -                -                -                -                -                -
GPU[0]      :   1 3D_FULL_SCREEN :        0              100               30                0              100               10
GPU[0]      :   2     POWER_SAVING:       10                0               30                -                -                -
GPU[0]      :   3            VIDEO:        -                -                -               10               16               31
GPU[0]      :   4               VR:        0               11               50                0              100               10
GPU[0]      :   5          COMPUTE:        0                5               30                -                -                -
GPU[0]      :   6           CUSTOM:        -                -                -                -                -                -
================================================================================================
=======================               End of ROCm SMI Log              ========================

And I can any other power profiles successfully, for example: rocm-smi --setprofile 5

========================        ROCm System Management Interface        ========================
================================================================================================
GPU[0]      : 
GPU[0]      : NUM        MODE_NAME     SCLK_UP_HYST   SCLK_DOWN_HYST SCLK_ACTIVE_LEVEL     MCLK_UP_HYST   MCLK_DOWN_HYST MCLK_ACTIVE_LEVEL
GPU[0]      :   0   BOOTUP_DEFAULT:        -                -                -                -                -                -
GPU[0]      :   1   3D_FULL_SCREEN:        0              100               30                0              100               10
GPU[0]      :   2     POWER_SAVING:       10                0               30                -                -                -
GPU[0]      :   3            VIDEO:        -                -                -               10               16               31
GPU[0]      :   4               VR:        0               11               50                0              100               10
GPU[0]      :   5        COMPUTE *:        0                5               30                0              100               10
GPU[0]      :   6           CUSTOM:        -                -                -                -                -                -
================================================================================================
========================               End of ROCm SMI Log              ========================

I have the latest version of ROCm from AMD repos on Ubuntu 16.04. Thank you!

jlgreathouse commented 5 years ago

I believe to set a custom profile, you need to actually fully define the profile in your command.

SMU7 (which is used on Polaris 10 GPUs like what you have) requires 8 values to be passed in to define those profiles. This is defined in smu7_set_power_profile_mode in the smu7_hwmgr.c file in your driver.

The fields are, in order:

  1. Do you want to have a custom SCLK (graphics clock) profile? 1 if yes, 0 if no.
  2. SCLK_UP_HYST
  3. SCLK_DOWN_HYST
  4. SCLK_ACTIVE_LEVEL
  5. Do you want to have a custom MCLK (memory clock) profile? 1 if yes, 0 if no.
  6. MCLK_UP_HYST
  7. MCLK_DOWN_HYST
  8. MCLK_ACTIVE_LEVEL

These values are all in a quoted string argument to --setprofile. For example, this is an example of setting the custom profile to be identical to the 3D_FULL_SCREEN profile on my Fiji (also SMU7) GPU:

$ rocm-smi -d 1 --showprofile

========================        ROCm System Management Interface        ========================
================================================================================================
GPU[1]          :
GPU[1]          : NUM        MODE_NAME     SCLK_UP_HYST   SCLK_DOWN_HYST SCLK_ACTIVE_LEVEL     MCLK_UP_HYST   MCLK_DOWN_HYST MCLK_ACTIVE_LEVEL
GPU[1]          :   0   BOOTUP_DEFAULT:        -                -                -                -                -                -
GPU[1]          :   1 3D_FULL_SCREEN *:        0              100               30                0              100               10
GPU[1]          :   2     POWER_SAVING:       10                0               30                -                -                -
GPU[1]          :   3            VIDEO:        -                -                -               10               16               31
GPU[1]          :   4               VR:        0               11               50                0              100               10
GPU[1]          :   5          COMPUTE:        0                5               30                -                -                -
GPU[1]          :   6           CUSTOM:        -                -                -                -                -                -
================================================================================================
========================               End of ROCm SMI Log              ========================

$ rocm-smi -d 1 --setprofile "1 0 100 30 1 0 100 10"

========================        ROCm System Management Interface        ========================
GPU[1]          : Successfully set CUSTOM Power Profile values
========================               End of ROCm SMI Log              ========================

$ rocm-smi -d 1 --showprofile

========================        ROCm System Management Interface        ========================
================================================================================================
GPU[1]          :
GPU[1]          : NUM        MODE_NAME     SCLK_UP_HYST   SCLK_DOWN_HYST SCLK_ACTIVE_LEVEL     MCLK_UP_HYST   MCLK_DOWN_HYST MCLK_ACTIVE_LEVEL
GPU[1]          :   0   BOOTUP_DEFAULT:        -                -                -                -                -                -
GPU[1]          :   1   3D_FULL_SCREEN:        0              100               30                0              100               10
GPU[1]          :   2     POWER_SAVING:       10                0               30                -                -                -
GPU[1]          :   3            VIDEO:        -                -                -               10               16               31
GPU[1]          :   4               VR:        0               11               50                0              100               10
GPU[1]          :   5          COMPUTE:        0                5               30                -                -                -
GPU[1]          :   6         CUSTOM *:        0              100               30                0              100               10
================================================================================================
========================               End of ROCm SMI Log              ========================
sabbaghm commented 5 years ago

@jlgreathouse Thank you! I could successfully set the custom profile using the suggested command template: rocm-smi --setprofile "CustomSCLKFlag SCLK_UP_HYST SCLK_DOWN_HYST SCLK_ACTIVE_LEVEL CustomMCLKFlag MCLK_UP_HYST MCLK_DOWN_HYST MCLK_ACTIVE_LEVEL"