几行代码搞定 import os # 我的电脑是两张显卡,编码分别为1,2 os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' import tensorflow as tf strategy = tf.distribute.MirroredStrategy() with strategy.scope()