def on_timeout(self, user_data): global progress, progress_text self.progressbar.set_fraction(progress) self.progressbar.set_text(progress_text) if reboot == True: Dialog("Reboot", "Press OK to reboot.") pp("/sbin/reboot") quit() return True
def GetValues(i, gpu): #Get GPU's stats function def GetValue(ppfile, i): #Getting AMD GPU's IDs s = pp('cat /sys/class/drm/card%s/device/%s | grep "*"' % (str(i), ppfile)) return s global gpus gpu = { 'corestate': "0", 'memstate': "0", 'voltstate': "0", 'coreclock': "0", 'memclock': "0", 'voltage': "0", 'fan-speed': "0", 'gpu-power': "0", 'temp': "0" } gpus.update({i: gpu}) s = GetValue('pp_dpm_sclk', i).read() parts = s.rsplit(': ', 2) gpus[i]['coreclock'] = parts[1][:-3] gpus[i]['corestate'] = parts[0] s = GetValue('pp_dpm_mclk', i).read() parts = s.rsplit(': ', 2) gpus[i]['memclock'] = parts[1][:-3] gpus[i]['memstate'] = parts[0] sv = pp( "ohgodatool -i %s --show-core | grep -A 1 'DPM state %s:' | grep VDDC" % (str(i), gpus[i]['corestate'])).read() sv = sv[7:] volt = sv.rsplit(' (', 2) gpus[i]['voltage'] = volt[0] gpus[i]['voltstate'] = volt[1][20:-2] s = pp("ohgodatool -i %s --show-fanspeed" % i).read() gpus[i]['fan-speed'] = s[:-2] s = pp("ohgodatool -i %s --show-temp" % i).read() gpus[i]['temp'] = s[:-2] s = pp("rocm-smi -d %s -P | grep Average" % str(i)).read() s = s[:-1] sp = s.rsplit('wer: ', 2) gpus[i]['gpu-power'] = sp[1]
def GetParam(gpu, param): # gets GPU's params def get(param): return int(pp('nvidia-settings -q "' + param + '" -t').read()) if param is "fan": return get('[fan:%s]/GPUTargetFanSpeed' % gpu) if param is "coreclock": return get('[gpu:%s]/GPUGraphicsClockOffset' % gpu) if param is "memclock": return get('[gpu:%s]/GPUMemoryTransferRateOffset' % gpu) if param is "pl": return float( pp("nvidia-smi --id=%s --query-gpu=power.limit --format=csv,noheader,nounits" % gpu).read())
def __init__(self): global oldkernel Gtk.Window.__init__(self, title="Upgrading system for AMD OC") self.set_default_size(500, 150) label = Gtk.Label() if oldkernel is True: label.set_markup( "<big>Hello!</big>\n" "Your Linux kernel version is: " + pp("uname -r").read() + "" "It will be upgraded to version 4.17 because there are some OC problems\n" "on older kernels with AMD. Overclocking software will be installed too." ) #window text else: label.set_markup( "<big>Hello!</big>\n" "Your Linux kernel version is: " + pp("uname -r").read() + "" "Only overclocking software will be installed.") #window text box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) box.set_homogeneous(False) box.pack_start(label, True, True, 0) self.button = Gtk.Button(label="Install") self.button.connect("clicked", self.on_button_clicked) self.progressbar = Gtk.ProgressBar() self.progressbar.set_show_text(True) box.pack_start(self.progressbar, True, True, 0) box.pack_start(self.button, True, True, 0) self.add(box) self.timeout_id = GLib.timeout_add(50, self.on_timeout, None) self.activity_mode = False self.show_all()
def on_applyall_clicked(self, button): global gpus, selectedgpu if self.power.get_text().isdigit() and self.cclk.get_text().isdigit( ) and self.mclk.get_text().isdigit() and self.fan.get_text().isdigit( ) and self.volt.get_text().isdigit() and not selectedgpu == None: cmd = "ohgodatool -i %s --core-state %s --core-clock %s" % ( str(selectedgpu), gpus[selectedgpu]['corestate'], self.cclk.get_text()) output = pp(cmd).read() print(cmd) sleep(2) cmd = "ohgodatool -i %s --mem-state %s --mem-clock %s" % ( str(selectedgpu), gpus[selectedgpu]['memstate'], self.mclk.get_text()) output = output + "\n" + pp(cmd).read() print(cmd) sleep(2) cmd = "ohgodatool -i %s --volt-state %s --vddc-table-set %s" % ( str(selectedgpu), gpus[selectedgpu]['voltstate'], self.volt.get_text()) output = output + "\n" + pp(cmd).read() print(cmd) sleep(2) cmd = "ohgodatool -i %s --set-fanspeed %s" % (str(selectedgpu), self.fan.get_text()) output = output + "\n" + pp(cmd).read() print(cmd) sleep(2) cmd = "ohgodatool -i %s --set-max-power %s" % ( str(selectedgpu), self.power.get_text()) output = output + "\n" + pp(cmd).read() print(cmd) sleep(2) Dialog("Info", "Result:\n<small>" + output + "</small>") else: Dialog("Error!", "Input data is incorrect or GPU is not selected!")
def run(self): count = int( pp("nvidia-smi --id=0 --query-gpu=count --format=csv,noheader"). read()) for i in range(0, count): NvidiaOC.gpus[str(i)] = { "fanspeed": GetParam(i, "fan"), "powerlimit": GetParam(i, "pl"), "coreclock": GetParam(i, "coreclock"), "memclock": GetParam(i, "memclock") } for i in gpus: NvidiaOC.gpu_selector.append_text("GPU " + i) NvidiaOC.mainwindow.show_all()
def on_power_clicked(self, button): global gpus, selectedgpu if self.power.get_text().isdigit() and not selectedgpu == None: cmd = "ohgodatool -i %s --set-max-power %s" % ( str(selectedgpu), self.power.get_text()) output = pp(cmd).read() print(cmd) sleep(2) Dialog("Info", "Result:\n<small>" + output + "</small>") GetValues(selectedgpu, gpus) self.cur_cclk.set_text(gpus[selectedgpu]['coreclock']) self.cur_mclk.set_text(gpus[selectedgpu]['memclock']) self.cur_volt.set_text(gpus[selectedgpu]['voltage']) self.cur_fan.set_text(gpus[selectedgpu]['fan-speed']) self.cur_power.set_text(gpus[selectedgpu]['gpu-power']) else: Dialog("Error!", "Input data is incorrect or GPU is not selected!")
def SetParam(gpu, param, val): # changes GPU's params def apply(param): return pp('nvidia-settings -a "' + param + '"').read() if param is "fan": result = apply('[gpu:%s]/GPUFanControlState=1' % gpu) result += apply('[fan:%s]/GPUTargetFanSpeed=%s' % (gpu, val)) return result if param is "coreclock": result = apply('[gpu:%s]/GPUGraphicsClockOffset[2]=%s' % (gpu, val)) result += apply('[gpu:%s]/GPUGraphicsClockOffset[3]=%s' % (gpu, val)) return result if param is "memclock": result = apply('[gpu:%s]/GPUMemoryTransferRateOffset[2]=%s' % (gpu, val)) result += apply('[gpu:%s]/GPUMemoryTransferRateOffset[3]=%s' % (gpu, val)) return result if param is "pl": result = pp('nvidia-smi --id=%s --power-limit=%s' % (gpu, val)).read() return result if param is "other": result = apply(val) return (result)
def GetValue(ppfile, i): #Getting AMD GPU's IDs s = pp('cat /sys/class/drm/card%s/device/%s | grep "*"' % (str(i), ppfile)) return s
def on_button_clicked(self, button): self.button.set_sensitive(False) ProgressThread().start() def on_timeout(self, user_data): global progress, progress_text self.progressbar.set_fraction(progress) self.progressbar.set_text(progress_text) if reboot == True: Dialog("Reboot", "Press OK to reboot.") pp("/sbin/reboot") quit() return True if not '4.18' in pp("uname -r").read(): install = InstallWindow() install.set_position(Gtk.WindowPosition.CENTER_ALWAYS) install.set_resizable(False) install.connect("destroy", Gtk.main_quit) install.show_all() Gtk.main() elif '4.18' in pp("uname -r").read() and not aptCache()['gedit'].is_installed: oldkernel = False install = InstallWindow() install.set_position(Gtk.WindowPosition.CENTER_ALWAYS) install.set_resizable(False) install.connect("destroy", Gtk.main_quit) install.show_all() Gtk.main() else:
def apply(param): return pp('nvidia-settings -a "' + param + '"').read()
def get(param): return int(pp('nvidia-settings -q "' + param + '" -t').read())
def on_edit_oc_clicked(self, button): pp("leafpad /etc/miners/nvidia_oc.json")
def factor(q): q = pp('factor ' + str(q)).read() q = q.split(':')[1].split() q = list(map(int, q)) return q
def on_button_clicked(self, button): self.button.set_sensitive(False) ProgressThread().start() def on_timeout(self, user_data): global progr, progrtext self.progressbar.set_fraction(progr) self.progressbar.set_text(progrtext) if reboot == True: Dialog("Reboot", "Press OK to reboot.") pp("/sbin/reboot") quit() return True if not '4.17' in pp("uname -r").read(): install = InstallWindow() install.set_position(Gtk.WindowPosition.CENTER_ALWAYS) install.set_resizable(False) install.connect("destroy", Gtk.main_quit) install.show_all() Gtk.main() elif '4.17' in pp("uname -r").read() and not path.exists( '/usr/src/OhGodATool') or not path.exists('/usr/src/ROC-smi'): oldkernel = False install = InstallWindow() install.set_position(Gtk.WindowPosition.CENTER_ALWAYS) install.set_resizable(False) install.connect("destroy", Gtk.main_quit) install.show_all() Gtk.main()