我目前正在Paperspace/Gradient Notebooks上训练CNN(Python 3.8.10,Tensorflow 2.7.0)
训练需要惊人的时间,似乎超过200%的CPU被利用,但只有15-20%的GPU。Tensorflow似乎认识到了GPU:
此外,我按照他们的模板使用tf.device()设置训练:
try:
with tf.device('/device:GPU:0'):
model_Sezer.fit(train_dataset,
epochs = 100,
validation_data = validation_dataset,
callbacks = [tensorboard_callback, checkpoint_Accuracy,],
class_weight = class_weight
)
except RuntimeError as e:
print(e)
有人知道如何在GPU上进行完整训练吗?
1条答案
按热度按时间w46czmvw1#
确保您拥有支持CUDA的NVIDIA GPU,并安装了CUDA Toolkit。阅读this文章了解有关先决条件的更多信息。
这就是我在所有项目中使用的。这需要在主文件的顶部,如果它能够找到GPU设备,就应该工作,不需要在
tf.device()
上运行它。