use:: import pynvml install:: pip3 install nvidia-ml-py3 github:: nicolargo/nvidia-ml-py3 doc::
import pynvml
pynvml.nvmlInit() # 初始化
pynvml.nvmlSystemGetDriverVersion() # 获取驱动版本信息
pynvml.nvmlDeviceGetCount() # 获取显卡数量
pynvml.nvmlShutdown() # 退出