无法使用gpu进行模型训练,但tensorflow正在使用gpu

问题描述 投票:0回答:1
I've been encountering an issue while working with TensorFlow GPU version 2.9.0 after configuring CUDA 11.6, ensuring compatibility with cuDNN, and setting up the necessary environment variables. Initially, I ran a code snippet to check if my GPU was detected:
import tensorflow as tf

打印(tf.config.list_physical_devices('GPU')) 输出确认 GPU 已被识别。

However, when I attempted to train my model using the GPU, I encountered a "resources exhausted" error. Upon checking the Task Manager, I noticed that the system was still primarily utilizing CPU RAM, neglecting the GPU.

以下是图片供参考: GPU configured Resources usage Error

我非常感谢任何见解或解决方案来理解为什么 GPU 在模型训练期间被识别但未被利用。关于此事的任何帮助都非常有价值!

tensorflow gpu
1个回答
0
投票

您提供的有关要训练的神经网络的信息非常少,因此不可能进行精确分析。然而,“资源耗尽”给了你一个强烈的暗示,即GPU内存已过期。此外,错误发生在分配之前的事实表明需要更多内存。由于内存分配检查失败,甚至没有分配,所以在任务管理器中看不到GPU的使用情况。

由于形状为 128,128,32,32 的张量引起了问题,因此必须减小其大小。如果其中一个维度对应于batch_size,我强烈建议首先减少这个数量。同样,为了进行更深入的分析,需要有关您的代码的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.