Skip to content

Instantly share code, notes, and snippets.

@gumdropsteve
Created August 10, 2020 04:21
Show Gist options
  • Save gumdropsteve/f1292ec1e36b818690614c4ad1bcabb9 to your computer and use it in GitHub Desktop.
Save gumdropsteve/f1292ec1e36b818690614c4ad1bcabb9 to your computer and use it in GitHub Desktop.
Check Google Colab GPU Type for RAPIDS Compatibility
import pynvml
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
device_name = pynvml.nvmlDeviceGetName(handle)
if (device_name != b'Tesla T4') and (device_name != b'Tesla P4') and (device_name != b'Tesla P100-PCIE-16GB'):
raise Exception("""
Unfortunately this instance does not have a T4, P4 or P100 GPU.\n
Please make sure you've configured Colab to request a GPU instance type.\n
Sometimes Colab allocates a Tesla K80 instead of a T4, P4 or P100. Resetting the instance.If you get a K80 GPU, try Runtime -> Reset all runtimes...""")
else:
print('Woo! You got the right kind of GPU!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment