【问题标题】:GPU sync failed when run two .py files at the same time in Pycharm在 Pycharm 中同时运行两个 .py 文件时,GPU 同步失败
【发布时间】:2020-10-31 06:31:31
【问题描述】:

我使用Pycharm运行A.py,当我开始在同一个项目下运行另一个B.py文件时,我得到了关于A.py的错误,说:

tensorflow.python.framework.errors_impl.InternalError: GPU sync failed

这两个文件都使用了tensorflow-GPU,每次我开始运行第二个文件时都不会出现这个错误。

有人知道原因吗? TIA。

【问题讨论】:

    标签: tensorflow pycharm


    【解决方案1】:

    似乎最常见的原因可能是您的 GPU 内存不足。那么允许内存增长会有所帮助。

    这可以通过调用 [tf.config.experimental.set_memory_growth][1] 来完成,它会尝试仅分配运行时分配所需的 GPU 内存。

    physical_devices = tf.config.list_physical_devices('GPU')
    try:
      tf.config.experimental.set_memory_growth(physical_devices[0], True)
    except RuntimeError as e:
      # Invalid device or cannot modify virtual devices once initialized.
      print(e)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-27
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 2014-06-24
      相关资源
      最近更新 更多