Step1:先安装pynvml
pip install pynvml
Step2:使用如下代码
from pynvml import *
nvmlInit()
deviceCount = nvmlDeviceGetCount()#几块显卡
print(deviceCount)
for i in range(deviceCount):
handle = nvmlDeviceGetHandleByIndex(i)
print ("Device", i, ":", nvmlDeviceGetName(handle)) #具体是什么显卡