【问题标题】:Run twice occurred gpu error on Google Colaboratory在 Google Colaboratory 上运行两次出现 gpu 错误
【发布时间】:2018-12-06 02:58:08
【问题描述】:

我想测试FIFIQueue,当我使用"with tf.device("/device:GPU:0"):"时,第一次运行还可以,但是运行两次就出错了just print 无法将 gpu 分配给 fifo_queue_EnqueueMany(错误详情如下图),有热心人帮帮我吗?

enter image description here enter image description here

【问题讨论】:

    标签: tensorflow google-colaboratory


    【解决方案1】:

    根据 drpng 在Tensorflow: using a FIFO queue for code running on GPUs 上的注释,我不希望 FIFOQueue 在 GPU 上调度,并且确实将您的代码包装在 .py 文件中(以查看 TF 的日志输出)和日志设备放置确认即使是第一个(成功) CPU 上的调用计划。

    在一个单元格中运行:

    %%writefile go.py
    
    import tensorflow as tf
    
    config = tf.ConfigProto()
    #config.allow_soft_placement=True
    config.gpu_options.allow_growth = True
    config.log_device_placement=True
    
    def go():
      Q = tf.FIFOQueue(3, tf.float16)
      enq_many = Q.enqueue_many([[0.1, 0.2, 0.3],])
      with tf.device('/device:GPU:0'):
        with tf.Session(config=config) as sess:
          sess.run(enq_many)
          print(Q.size().eval())
    
    go()
    go()
    

    在另一个单元格中执行上述操作:

    !python3 go.py
    

    并观察放置。

    取消注释allow_soft_placement 分配以使崩溃消失。

    (当要求 FIFOQueue 像在代码的“第一次”中那样在 GPU 上显式调度时,我不知道为什么即使面对非软放置,第一次执行也会成功)

    【讨论】:

    • 感谢您的建议,也许我应该在 CPU 而不是 GPU 上运行 FIFIQueue~
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-14
    • 2019-01-11
    • 1970-01-01
    • 2021-04-18
    • 2020-08-09
    • 1970-01-01
    • 2018-09-26
    相关资源
    最近更新 更多