-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverclock.js
44 lines (42 loc) · 1.21 KB
/
overclock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { exec } = require('child_process')
const settingsApp = 'DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 nvidia-settings'
const numGPUS = Number(process.env.GPUCOUNT) || 1
function runSettingsApp (cmd, done) {
const _cmd = settingsApp + ' -a ' + cmd
console.log(cmd)
exec(_cmd, (error, stdout, stderr) => {
if (error) {
return console.log(error)
}
})
}
exports.overclock = (opts) => {
let cmd = `nvidia-smi -pm 0`
exec(cmd, (error, stdout, stderr) => {
if (error) {
return console.log(error)
}
cmd = `nvidia-smi -pl ${opts.powerlimit}`
opts.powerlimit && exec(cmd, (error, stdout, stderr) => {
if (error) {
return console.log(error)
}
})
if (opts.core) {
for (let i = 0; i < numGPUS; i++) {
runSettingsApp(`[gpu:${i}]/GPUGraphicsClockOffset[3]=${opts.core}`)
}
}
if (opts.mem) {
for (let i = 0; i < numGPUS; i++) {
runSettingsApp(`[gpu:${i}]/GPUMemoryTransferRateOffset[3]=${opts.mem}`)
}
}
if (opts.fan) {
for (let i = 0; i < numGPUS; i++) {
runSettingsApp(`[gpu:${i}]/GPUFanControlState=1`)
runSettingsApp(`[fan:${i}]/GPUTargetFanSpeed=${opts.fan}`)
}
}
})
}