Which NVML API call do I use to set the SM clock of an NVIDIA GPU?

It won’t allow you to do overclocking or underclocking (i.e. if GPU would not normally go to the specified frequency this call won’t make it), but it will try to keep clocks within/as close as possible to specified limit otherwise.

Honestly, just go with nvmlDeviceSetGpcClkVfOffset for now, it says “will be deprecated in a future release” anyways. I’ve tried out new functions and they don’t seem to be particularly production ready: nvmlDeviceGetMinMaxClockOfPState/nvmlDeviceSetClockOffsets issues.

If you want to lock clocks to a specified frequency that your device already goes to, just nvmlDeviceSetGpuLockedClocks should do. If it’s above the normal limit (i.e. you want to overclock), call nvmlDeviceSetGpcClkVfOffset with target frequency - normal max frequency as offset, then nvmlDeviceSetGpuLockedClocks with the target frequency as both values only if you want GPU to stay at that frequency at all times (not needed to just reach it under appropriately high load).

P.S.: here’s a short summary by Nvidia itself on pstates: NVAPI Reference Documentation; in NVML you’d want to look at nvmlDeviceGetSupportedPerformanceStates and from there nvmlDeviceGetMinMaxClockOfPState, but the caveat from linked post applies.