Skip to content

Instantly share code, notes, and snippets.

@jzuern
Created November 7, 2018 10:05
Show Gist options
  • Save jzuern/5073f769a0cf263676b404bd1b7d85de to your computer and use it in GitHub Desktop.
Save jzuern/5073f769a0cf263676b404bd1b7d85de 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