首页 > 解决方案 > 一旦我的 tf2 模型开始训练,显示器就会变黑

问题描述

我用自己的图像数据创建了我的第一个模型。一开始训练效果很好,但现在我想通过更多的时期来达到更好的准确性。突然,当我开始训练时,显示器变黑了。我仍然可以在这里播放音乐,所以我认为它可能只是一些 gpu 的东西等。但显示器再也没有上线。我在网上浏览了不同的帖子,但无法找到解决方案。我试图限制分配的 gpu 内存。没有任何改进。

首先我试过:

gpus = tf.config.experimental.list_physical_devices('GPU')
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

if gpus:
  try:
    for gpu in gpus:
      tf.config.experimental.set_memory_growth(gpu, True)

  except RuntimeError as e:
    print(e)

然后我尝试了:

gpus = tf.config.experimental.list_physical_devices('GPU')
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

if gpus:
  try:
    tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5000)])

  except RuntimeError as e:
    print(e)

我用nvidia-smi检查了使用情况,它告诉我,只分配了 5000 个。

知道我需要做什么吗?

标签: pythontensorflow

解决方案


我想到了。这很明显。我安装的 Cuda 版本是 10.2,不知何故,我没有最新的 tensorflow 2.1.0 版本,而是启动并运行了 2.0.0 版本。使用 conda 和更新 tensorflow 解决了这个问题。


推荐阅读