Log a fatal error if RemoteDevice::resource_manager() is called.

PiperOrigin-RevId: 264849833
diff --git a/tensorflow/core/common_runtime/eager/context.cc b/tensorflow/core/common_runtime/eager/context.cc
index 8133ef3..a989de3 100644
--- a/tensorflow/core/common_runtime/eager/context.cc
+++ b/tensorflow/core/common_runtime/eager/context.cc
@@ -351,7 +351,8 @@
   if (step_container_ == nullptr) {
     step_container_.reset(
         new ScopedStepContainer(0, [this](const string& name) {
-          for (Device* device : devices_) {
+          auto local_devices = local_device_mgr()->ListDevices();
+          for (Device* device : local_devices) {
             device->resource_manager()->Cleanup(name).IgnoreError();
           }
         }));
diff --git a/tensorflow/core/distributed_runtime/remote_device.cc b/tensorflow/core/distributed_runtime/remote_device.cc
index df93aa7..a29eaa4 100644
--- a/tensorflow/core/distributed_runtime/remote_device.cc
+++ b/tensorflow/core/distributed_runtime/remote_device.cc
@@ -40,6 +40,11 @@
   Status Sync() override { return Status::OK(); }
   Allocator* GetAllocator(AllocatorAttributes attr) override { return nullptr; }
 
+  ResourceMgr* resource_manager() override {
+    LOG(FATAL) << "Accessing the resource manager of a remote device is not "
+               << "supported.";
+  }
+
   bool IsLocal() const override { return false; }
 
  private: