Win10 refreshes NVIDIA-SMI graphics card information in real time

python program

nvidia_smi.py

import time
import subprocess
import locale
import codecs
import os
cmd = "nvidia-smi"
interval = 1
while True:
    ps = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
    while True:
        data = ps.stdout.readline()
        data = str(data)
        if data == "b''":
            break
        if data.startswith('b\''):
            data = data[2:]
        if data.endswith('\\r\\n\''):
            data = data[:len(data)-5]
        data = data.replace('\\\\', '\\')
        print(data)
    print("\n\n\n\n\n\n\n")
    time.sleep(interval)
    os.system("cls")

package command

pyinstaller -F nvidia_smi.py

The effect after adding to the environment variable

nvidia-smi

resource acquisition

Click here to download, of course, you can generate one yourself according to the blog, and the students who download it will be regarded as punishment

Guess you like

Origin blog.csdn.net/qq_39567427/article/details/118096362