Search code examples
pythonnvidia

can not import nvidia_smi


I'm tending to collect my GPU status during my python code is running. I need to import nvidia_smi in my code to do this. but even by installing it by pip install nvidia_smi hit this error: No module named 'nvidia_smi'

Any Idea?


Solution

  • I found the answer here just pip install nvidia-ml-py3:

    and:

    import nvidia_smi
    
    nvidia_smi.nvmlInit()
    handle = nvidia_smi.nvmlDeviceGetHandleByIndex(0)