How to limit max GPU usage to certain percent

For our application, sometimes max GPU usage can be update to 99%. Is there any way to limit the max GPU usage to certain percent (Just like cgroup to limit cpu usage). For example limit the max GPU usage to 90%?

[2020-05-24 09:10:31] : RAM 4344/6847MB (lfb 15x4MB) CPU [36%@1920,94%@1958,70%@1958,26%@1920,85%@1920,25%@1919] EMC_FREQ 31%@1600 GR3D_FREQ 8%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C P
[2020-05-24 09:10:36] : RAM 4343/6847MB (lfb 15x4MB) CPU [39%@1921,71%@1958,97%@1957,24%@1920,88%@1921,25%@1922] EMC_FREQ 32%@1600 GR3D_FREQ 41%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@51.5
[2020-05-24 09:10:41] : RAM 4356/6847MB (lfb 15x4MB) CPU [49%@1901,95%@1958,78%@1957,34%@1902,89%@1905,34%@1908] EMC_FREQ 31%@1600 GR3D_FREQ 0%@1134 APE 158 MTS fg 0% bg 0% BCPU@53.5C MCPU@53.5C GPU@5
[2020-05-24 09:10:46] : RAM 4345/6847MB (lfb 15x4MB) CPU [41%@1918,99%@1958,68%@1958,25%@1920,88%@1921,32%@1919] EMC_FREQ 32%@1600 GR3D_FREQ 99%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@52C 
[2020-05-24 09:10:51] : RAM 4346/6847MB (lfb 15x4MB) CPU [42%@1920,99%@1957,69%@1958,27%@1921,86%@1919,29%@1920] EMC_FREQ 32%@1600 GR3D_FREQ 99%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@52.5
[2020-05-24 09:10:56] : RAM 4345/6847MB (lfb 15x4MB) CPU [42%@1904,99%@1959,71%@1958,25%@1906,92%@1905,27%@1905] EMC_FREQ 32%@1600 GR3D_FREQ 0%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@52C P
[2020-05-24 09:11:01] : RAM 4346/6847MB (lfb 15x4MB) CPU [38%@1920,100%@1958,70%@1957,31%@1919,89%@1919,29%@1919] EMC_FREQ 31%@1600 GR3D_FREQ 0%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@52.5
[2020-05-24 09:11:06] : RAM 4345/6847MB (lfb 15x4MB) CPU [55%@1920,99%@1959,73%@1958,35%@1920,87%@1920,32%@1919] EMC_FREQ 32%@1600 GR3D_FREQ 0%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C P
[2020-05-24 09:11:11] : RAM 4345/6847MB (lfb 15x4MB) CPU [40%@1920,99%@1958,69%@1958,26%@1920,87%@1921,31%@1920] EMC_FREQ 32%@1600 GR3D_FREQ 11%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C 
[2020-05-24 09:11:16] : RAM 4346/6847MB (lfb 15x4MB) CPU [43%@1909,99%@1958,69%@1959,26%@1915,87%@1908,28%@1909] EMC_FREQ 31%@1600 GR3D_FREQ 19%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C 
[2020-05-24 09:11:21] : RAM 4346/6847MB (lfb 15x4MB) CPU [38%@1911,97%@1959,74%@1958,25%@1913,89%@1909,25%@1914] EMC_FREQ 31%@1600 GR3D_FREQ 99%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C 
[2020-05-24 09:11:26] : RAM 4347/6847MB (lfb 15x4MB) CPU [47%@1920,78%@1958,97%@1958,37%@1919,84%@1920,32%@1920] EMC_FREQ 31%@1600 GR3D_FREQ 33%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C 
[2020-05-24 09:11:31] : RAM 4346/6847MB (lfb 15x4MB) CPU [42%@1920,99%@1958,69%@1958,27%@1921,93%@1920,25%@1920] EMC_FREQ 31%@1600 GR3D_FREQ 99%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@52.5
[2020-05-24 09:11:36] : RAM 4345/6847MB (lfb 15x4MB) CPU [43%@1907,72%@1958,96%@1958,26%@1911,94%@1908,29%@1908] EMC_FREQ 31%@1600 GR3D_FREQ 0%@1134 APE 158 MTS fg 0% bg 0% BCPU@53C MCPU@53C GPU@53C P
[2020-05-24 09:11:41] : RAM 4347/6847MB (lfb 15x4MB) CPU [41%@1911,85%@1957,83%@1960,25%@1911,93%@1913,27%@1912] EMC_FREQ 32%@1600 GR3D_FREQ 15%@1134 APE 158 MTS fg 0% bg 0% BCPU

I don’t think there’s any way to limit the CPU/GPU usage. Only the clocks can be limit as support frequency.

I am curious what the reason might be to want to limit GPU use?

We found if enable GPU feature with 99% usage, sometimes TX2 will get hang and power off directly. And will never reboot automatically.

Therefore we doubt it is may power issue caused by GPU side.

If you can monitor “dmesg --follow” from serial console when it hangs, then you could probably find the reason. It shouldn’t hang. It could run out of memory and reboot, but if for example it turns out it is overheating and hanging, then you probably need to find out why. Limiting use could keep heat down and power consumption down, but you really should know why this is occurring before using something which may or may not work.

You can also try to slow down the GPU frequency to try it should be the same effect with limit the usage.