Cannot assign a device for operation 'HorovodAllreduce_random_uniform_0': Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU devices is available.

报错:Cannot assign a device for operation 'HorovodAllreduce_random_uniform_0': Could not satisfy explicit device specification '/device:GPU:1' because no supported kernel for GPU devices is available.

解决办法:加上 config = tf.ConfigProto(allow_soft_placement=True) ,默认使用 GPU

import tensorflow as tf
from time import sleep

a = tf.Variable([1,2,3,4,5])
# 加上下面一行
config = tf.ConfigProto(allow_soft_placement=True)

# 设置 gpu 随使用增长

config.gpu_options.allow_growth = True
sess = tf.Session(config=config)

sess.run(tf.global_variables_initializer())

print(sess.run(a))

  

猜你喜欢

转载自www.cnblogs.com/lixiaolun/p/9162614.html