推理
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()