Skip to content

Instantly share code, notes, and snippets.

@ThomasParistech
Last active November 1, 2023 22:57
Show Gist options
  • Save ThomasParistech/a991dd6fc4cdb9e1fa008ff024e83a67 to your computer and use it in GitHub Desktop.
Save ThomasParistech/a991dd6fc4cdb9e1fa008ff024e83a67 to your computer and use it in GitHub Desktop.
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