InvalidArgumentError-已明确分配给/ device:GPU:1,但可用的设备为[/ job:localhost /副本:0 / task:0 / device:CPU:0,

时间:2020-04-03 14:04:00

标签: python tensorflow error-handling gpu gpu-programming

任何帮助将不胜感激。我一般对tensorflow和编程都是陌生的。我正在按照github(https://github.com/experiencor/keras-yolo3)中的说明学习YOLO-3的对象检测。在运行下面的代码后。请尽快向我提供解决方案。

!python train.py -c config.json

我收到以下错误:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for` operation replica_1/lambda_6/Shape: node replica_1/lambda_6/Shape (defined at /home/arasdar/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py:1748) was explicitly assigned to /device:GPU:1 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0, /job:localhost/replica:0/task:0/device:XLA_CPU:0, /job:localhost/replica:0/task:0/device:XLA_GPU:0 ]. Make sure the device specification refers to a valid device. [[replica_1/lambda_6/Shape]]

1 个答案:

答案 0 :(得分:0)

检查config.json文件,如果仅使用单个GPU,则应将“ train”下的“ gpu”参数更改为“ 0”,而不是默认的“ 0,1”

"train": {
    "gpu":  "0"
}