相关疑难解决方法(0)

TensorFlow可以运行多个CPU(没有GPU)吗?

我正在尝试学习分布式TensorFlow.试过这里解释的片段代码:

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]))
Run Code Online (Sandbox Code Playgroud)

收到以下错误:

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(cat /proc/cpuinfo | grep processor | wc -l)的RedHat服务器上运行.

有任何想法吗?

python redhat python-2.7 tensorflow

6
推荐指数
1
解决办法
3584
查看次数

tensorflow如何分配Ops在GPU上运行?

我对tensorflow用于为CPU或GPU分配不同Ops的机制感到困惑.

  1. 以伪代码为例.我们可以说:只要SimpleOp在上下文中创建with tf.device('/gpu:0')它,它肯定会在GPU上运行(假设GPU的实现SimpleOp 是可用的),无论它的输入变量(in_1in_2)是在CPU还是GPU上创建的?

    with tf.device('/gpu:0'):
        out = tf.SimpleOp(in_1, in_2, name='Simple')
    
    Run Code Online (Sandbox Code Playgroud)
  2. 我理解通过创建sessionwith log_device_placement=True,tensorflow输出所有变量/ Ops的设备位置.但是,有没有一种方法可以让我只检查一个Op的设备分配?

提前致谢!

tensorflow

2
推荐指数
1
解决办法
2694
查看次数

标签 统计

tensorflow ×2

python ×1

python-2.7 ×1

redhat ×1