python - 一旦我的 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 个。
知道我需要做什么吗?
解决方案
我想到了。这很明显。我安装的 Cuda 版本是 10.2,不知何故,我没有最新的 tensorflow 2.1.0 版本,而是启动并运行了 2.0.0 版本。使用 conda 和更新 tensorflow 解决了这个问题。
推荐阅读
- c - C 编译器检查多个枚举中的重叠
- visual-studio - 尝试添加端口或depends_on时来自VS2019的docker-compose错误
- javascript - 如何单独暂停/播放 html5 视频
- swift - Safari 应用扩展 Popover 和 Command 同时
- python - Python Dash 计时器?
- python-3.x - Python中有没有一种方法可以将名称与值相乘?CSV
- javascript - 当我在 Javascript 中迭代一个数组时,推送它总是返回 javascript 中的最后一个索引
- c# - WPF ComboBox 不使用 SelectedIndex 显示默认值
- laravel - 如何根据策略使用 eloquent 加载元素?
- vb.net - 并行计算流的不同哈希值