我想并行使用 8 gpus,而不是按顺序使用。
例如,当我执行这段代码时,
import tensorflow as tf
with tf.device('/gpu:0'):
for i in range(10):
print(i)
with tf.device('/gpu:1'):
for i in range(10, 20):
print(i)
Run Code Online (Sandbox Code Playgroud)
我试过 cmd 命令 'CUDA_VISIBLE_DEVICE='0,1' 但结果是一样的。
我想看到结果“0 10 1 11 2 3 12 ....等”
但实际结果依次为“0 1 2 3 4 5 ..... 10 11 12 13..”
我怎样才能得到想要的结果?