修改Colab pro tensorflow 版本
问题:8月3号晚colab pro tensorflow版本默认改为2.3,致使之前TPU代码报错,或者需要将训练batchsize降低很多,代价是训练时间大量增加或者无法训练。
ResourceExhaustedError when using TPU #1470
解决方法:
暂时将tensorflow版本设定成2.2版本
添加如下代码即可:
!pip install tensorflow~=2.2.0 tensorflow_gcs_config~=2.2.0
import tensorflow as tf
import requests
import os
resp = requests.post("http://{}:8475/requestversion/{}".format(os.environ["COLAB_TPU_ADDR"].split(":")[0], tf.__version__))
if resp.status_code != 200:
print("Failed to switch the TPU to TF {}".format(version))```