autokeras icon indicating copy to clipboard operation
autokeras copied to clipboard

Support TPU

Open vincent-hui opened this issue 6 years ago • 5 comments

Is it possible to support TPU?

TPU can be used in colab https://colab.research.google.com/github/tensorflow/tpu/blob/master/tools/colab/fashion_mnist.ipynb

vincent-hui avatar Oct 21 '18 05:10 vincent-hui

@vincent-hui Yes, we are working on this issue. Please refer to #105 . Thanks.

haifeng-jin avatar Oct 23 '18 14:10 haifeng-jin

@haifeng-jin so is there TPU support in Colab for AutoKeras? Or do we have to stick with GPU’s?

neel04 avatar Dec 19 '20 04:12 neel04

This is a really old issue. I expect we already support TPU, but having some performance issues. Should be solved when we support compile function for AutoModels.

haifeng-jin avatar Feb 11 '21 20:02 haifeng-jin

If anyone is having any error caused by running AutoKeras on TPU. Please paste it here.

haifeng-jin avatar Feb 11 '21 20:02 haifeng-jin

Looks like TPU is supported as KerasTuner now supports TPU, here is an example: https://colab.research.google.com/drive/1AaFDTQaq8B5p3-FKtNDdMdhlmUHtwOIM?authuser=1#scrollTo=HUJ0LxZnbQnc

and it's quite simple actually with only 2 lines of code:

resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu=tpu_address)
strategy = tf.distribute.TPUStrategy(resolver)
clf = ak.ImageClassifier(max_trials=3, distribution_strategy=strategy)

Note: It looks like using with strategy.scope() will not work (same as KerasTuner) and the TPU strategy have to be passed down this way. I think it will be great if this is added somewhere in the documentation (I'm happy to contribute if needed), also thanks for the awesome package!

Edit: Actually there are some models generate that are not compatible with TPU will break, see the same colab above.

shun-lin avatar Feb 16 '21 01:02 shun-lin