Skip to content

Instantly share code, notes, and snippets.

@hristian-carabulea
Forked from jzuern/check-tpu.py
Created October 29, 2019 17:45
Show Gist options
  • Save hristian-carabulea/6c8cd4047113f1805d01af6de6f5c984 to your computer and use it in GitHub Desktop.
Save hristian-carabulea/6c8cd4047113f1805d01af6de6f5c984 to your computer and use it in GitHub Desktop.
import os
import pprint
import tensorflow as tf
if 'COLAB_TPU_ADDR' not in os.environ:
print('ERROR: Not connected to a TPU runtime; please see the first cell in this notebook for instructions!')
else:
tpu_address = 'grpc://' + os.environ['COLAB_TPU_ADDR']
print ('TPU address is', tpu_address)
with tf.Session(tpu_address) as session:
devices = session.list_devices()
print('TPU devices:')
pprint.pprint(devices)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment