[PYTHON] Create Cloud TPU with tf-nightly

Create Cloud TPU with tf-nightly

I want to use tf-nightly 2.x! But TPU doesn't support it. At that time, I was in trouble because there was no explanation, so I made a note.

First, set up to the point where you can use Google Cloud Shell. Then enter the following command.

ctpu tf-versions

Cloud TPU TensorFlow Versions:
	1.15	(default version)
	1.15.dev20190909
	1.15.dev20190821
	1.14
	1.14.1.dev20190518
	1.14.1.dev20190508
	1.13
	1.12
	1.11
	nightly
	nightly-2.x
	pytorch-0.1
	pytorch-0.5
	pytorch-nightly

Choose the version you want to use.

ctpu up -tf-version nightly-2.x

To choose tf2.0 nightly, do the above. You will be asked to enter y.

ctpu will use the following configuration:

  Name:                 your name
  Zone:                 us-central1-b
  GCP Project:          your_project
  TensorFlow Version:   nightly-2.x
  VM:
      Machine Type:     n1-standard-2
      Disk Size:        250 GB
      Preemptible:      false
  Cloud TPU:
      Size:             v2-8
      Preemptible:      false
      Reserved:         false

OK to create your Cloud TPU resources with the above configuration? [Yn]:

You can check the TPU with the following command.

gcloud compute tpus list

NAME             ZONE           ACCELERATOR_TYPE  NETWORK_ENDPOINTS  NETWORK  RANGE          STATUS
your_name        us-central1-b  v2-8              10.240.x.x:8470    default  10.240.x.x/29  READY

You can learn by specifying it as a resolver as follows.

resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu='grpc://10.240.x.x:8470')

Remarks

By the way, note that it will not work unless you specify / job: worker in strategy.scope and create a dataset or model as shown below.

with strategy.scope():
    with tf.device("/job:worker"):
			...

Recommended Posts

Create Cloud TPU with tf-nightly
Create games with Pygame
Create filter with scipy
Point Cloud with Pepper
Create an environment with virtualenv
Create an API with Django
Create / search / create table with PynamoDB
Create 3d gif with python3
Create graph with plotly button
Create a homepage with django
VFX cloud computing with Houdini
Create Image Viewer with Tkinter
Create custom rules with ElastAlert
Create patent map with Streamlit
Create a heatmap with pyqtgraph
Enhanced vocabulary with Cloud Text-to-Speech
Create a directory with python
Create xlsx file with XlsxWriter
Create a word cloud with only positive / negative words on Twitter
Create plot animation with Python + Matplotlib
[Package cloud] Manage python packages with package cloud
Create Awaitable with Python / C API
Create screen scroll with Pythonista + scene
[AWS] Create API with API Gateway + Lambda
Create folders from '01' to '12' with python
Easy Jupyter environment construction with Cloud9
Create a virtual environment with Python!
Create an Excel file with Python3
Run XGBoost with Cloud Dataflow (Python)
Create LGTM images with GIMP! (Python-fu)
Dynamically create new dataframes with pandas
Create noise-filled audio data with SoX
Create basic algorithms with Smart Trade
Create API using hug with mod_wsgi
Create an age group with pandas
Create a poisson stepper with numpy.random
Create github pages with lektor Part 1
Create a file uploader with Django