diff options
author | 2016-03-11 17:04:00 -0800 | |
---|---|---|
committer | 2016-03-11 20:45:42 -0800 | |
commit | 9849c30bb441d8bc07b5a5bb2efe0640ce46c97c (patch) | |
tree | a0d8a43eb332597500beb65f0e12a77aba84499b /tensorflow/core | |
parent | c5fc107300f7c89befcedf605622b571dd8b9f71 (diff) |
Improve SimplePlacer error message when a device does not exist.
This change distinguishes between the case where a device in the
NodeDef refers to an unknown device, and when it refers to a device
that exists but doesn't support a particular node.
Change: 117022320
Diffstat (limited to 'tensorflow/core')
-rw-r--r-- | tensorflow/core/common_runtime/simple_placer.cc | 22 | ||||
-rw-r--r-- | tensorflow/core/common_runtime/simple_placer_test.cc | 26 |
2 files changed, 45 insertions, 3 deletions
diff --git a/tensorflow/core/common_runtime/simple_placer.cc b/tensorflow/core/common_runtime/simple_placer.cc index 776cb748c0..5414b75fff 100644 --- a/tensorflow/core/common_runtime/simple_placer.cc +++ b/tensorflow/core/common_runtime/simple_placer.cc @@ -311,9 +311,25 @@ class ColocationGraph { // The specified device and merged set device match, and // will appear in the GraphDef (for debugging), so just // print the specified device. - return errors::InvalidArgument( - "Could not satisfy explicit device specification '", - node->def().device(), "'"); + std::vector<Device*> devices_matching_nodedef; + device_set_->FindMatchingDevices(specified_device_name, + &devices_matching_nodedef); + if (devices_matching_nodedef.empty()) { + return errors::InvalidArgument( + "Could not satisfy explicit device specification '", + node->def().device(), + "' because no devices matching that specification " + "are registered in this process"); + } else if (specified_device_name.has_type) { + return errors::InvalidArgument( + "Could not satisfy explicit device specification '", + node->def().device(), "' because no supported kernel for ", + specified_device_name.type, " devices is available"); + } else { + return errors::InvalidArgument( + "Could not satisfy explicit device specification '", + node->def().device()); + } } else { // The specified device may be a valid device but the // merged set device is different, so print both. diff --git a/tensorflow/core/common_runtime/simple_placer_test.cc b/tensorflow/core/common_runtime/simple_placer_test.cc index bb0bdcc216..cbc1c8341d 100644 --- a/tensorflow/core/common_runtime/simple_placer_test.cc +++ b/tensorflow/core/common_runtime/simple_placer_test.cc @@ -927,6 +927,32 @@ TEST_F(SimplePlacerTest, TestUnsupportedDeviceNoAllowSoftPlacement) { StringPiece(s.error_message()) .contains( "Could not satisfy explicit device specification '/cpu:0'")); + EXPECT_TRUE( + StringPiece(s.error_message()) + .contains("no supported kernel for CPU devices is available")); +} + +// Test that placement fails when a node requests an explicit device that is not +// supported by the registered kernels if allow_soft_placement is no set. +TEST_F(SimplePlacerTest, TestNonExistentDevice) { + Graph g(OpRegistry::Global()); + { // Scope for temporary variables used to construct g. + GraphDefBuilder b(GraphDefBuilder::kFailImmediately); + ops::SourceOp("VariableGPU", + b.opts().WithName("var").WithDevice("/job:foo/replica:17")); + TF_EXPECT_OK(BuildGraph(b, &g)); + } + + SessionOptions options; + Status s = Place(&g, &options); + EXPECT_EQ(error::INVALID_ARGUMENT, s.code()); + LOG(WARNING) << s.error_message(); + EXPECT_TRUE( + StringPiece(s.error_message()) + .contains("Could not satisfy explicit device specification " + "'/job:foo/replica:17' " + "because no devices matching that specification are " + "registered in this process")); } TEST_F(SimplePlacerTest, TestUnsupportedDeviceAllowSoftPlacement) { |