【发布时间】:2021-03-14 23:41:15
【问题描述】:
我正在尝试在 Colab 多核 TPU 上运行我的模型,但我真的不知道该怎么做。我尝试了this tutorial notebook,但出现了一些错误,我无法修复它,但我认为等待可能更简单。
关于我的模型:
class BERTModel(nn.Module):
def __init__(self,...):
super().__init__()
if ...:
self.bert_model = XLMRobertaModel.from_pretrained(...) # huggingface XLM-R
elif ...:
self.bert_model = others_model.from_pretrained(...) # huggingface XLM-R
... # some other model's parameters
def forward(self,...):
bert_input = ...
output = self.bert_model(bert_input)
... # some function that process on output
def other_function(self,...):
# just doing some process on output. like concat layers's embedding and return ...
class MAINModel(nn.Module):
def __init__(self,...):
super().__init__()
print('Using model 1')
self.bert_model_1 = BERTModel(...)
print('Using model 2')
self.bert_model_2 = BERTModel(...)
self.linear = nn.Linear(...)
def forward(self,...):
bert_input = ...
bert_output = self.bert_model(bert_input)
linear_output = self.linear(bert_output)
return linear_output
您能告诉我如何在 Colab TPU 上运行类似于我的模型的模型吗?我使用 Colab PRO 来确保 Ram 内存不是大问题。非常感谢你。
【问题讨论】:
-
分享收到的错误消息总是很有帮助的。请将完整的堆栈跟踪添加到您的问题中。
标签: pytorch google-colaboratory huggingface-transformers tpu google-cloud-tpu