Last active
November 1, 2023 22:57
-
-
Save ThomasParistech/a991dd6fc4cdb9e1fa008ff024e83a67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
import nvidia_smi | |
@lru_cache() | |
def is_gpu_available() -> bool: | |
"""Check if nvidia-smi is available.""" | |
try: | |
nvidia_smi.nvmlInit() | |
nvidia_smi.nvmlShutdown() | |
except Exception: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment