我在学习分布式TensorFlow。尝试了一块代码解释here:Can TensorFlow可以运行多个CPU(无GPU)?
with tf.device("/cpu:0"):
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
with tf.device("/cpu:1"):
y = tf.nn.softmax(tf.matmul(x, W) + b)
loss = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
得到以下错误:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'MatMul': Operation was explicitly assigned to /device:CPU:1 but available devices are [ /job:localhost/replica:0/task:0/cpu:0 ]. Make sure the device specification refers to a valid device. [[Node: MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:CPU:1"](Placeholder, Variable/read)]]
意思是说TensorFlow不能识别CPU:1。
我在有40个CPU的RedHat服务器上运行(cat /proc/cpuinfo | grep processor | wc -l
)。
任何想法?
你有40个CPU或40核心吗? – raam86
raam86根据https://askubuntu.com/questions/724228/how-to-find-the-number-of-cpu-cores-including-virtual 40 cpus –
我曾经使用过多个CPU处理使用sci-kit学习( GridSearchCV函数)在tensorflow骨干..所以我想这是可能的。然而,我不确定如何在tensorflow级别实现它 – Eduardo