推理
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0, 1' # 选择GPU设备
predict = model.predict(SignalSeq_16[:10])
训练
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
mirrored_strategy = tf.distribute.MirroredStrategy()
with mirrored_strategy.scope():
...
model =
model.compile()
model.fit()
model.save()
del model
gc.collect()

本文介绍了如何利用CUDA环境选择GPU设备进行预测,并探讨了在TensorFlow中设置GPU内存增长,实现分布式训练的流程。通过MirroredStrategy进行模型并行训练,提升了模型的训练效率,最后完成模型的保存和资源清理。
1157

被折叠的 条评论
为什么被折叠?



