【问题标题】:How to set specific gpu in bert?如何在bert中设置特定的gpu?
【发布时间】:2019-04-25 08:34:43
【问题描述】:

ResourceExhaustedError(回溯见上文):

分配形状 [768] 的张量并键入 float [[node bert/encoder/layer_0/attention/output/LayerNorm/beta/adam_m/Initializer/zeros (定义在 /home/zyl/souhu/bert/optimization.py:122)= const_class=["loc:@bert/encoder/layer_0/attention/output/LayerNorm/beta/adam_m/Assign"], dtype=DT_FLOAT, value=Tensor, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

如何设置 gpu 1 或另一个来运行 bert

【问题讨论】:

    标签: tensorflow nlp bert-language-model


    【解决方案1】:

    设置将使用哪些 GPU 的最简单方法是设置 CUDA_VISIBLE_DEVICES 环境变量。它仍然是GPU:0 TensorFlow,不同物理上不同的设备。

    如果您在 Python 中使用 BERT(这是一种相当痛苦的方式),您可以使用在块中创建 BERT 图的代码:

    with tf.device('/device:GPU:1'):
       model = modeling.BertModel(...)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多