-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Debugger Plugin] Exit TensorBoard on SIGINT even with debugger enabled #975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ This dashboard is in its **alpha release**. Some features are not yet fully func | |
|
||
To enable the debugger dashboard, pass the `debugger_port` flag to TensorBoard. TensorBoard will then both receive gRPC messages from and issue gRPC messages to model logic via this port. | ||
|
||
This command demonstrates how to set the debugger port to 6064. | ||
This command demonstrates how to set the debugger port to 6064. | ||
|
||
``` | ||
tensorboard \ | ||
|
@@ -166,10 +166,21 @@ For example, suppose a tensor has a shape of (500, 100), applying a slicing of ` | |
|
||
For each tensor, the time axis (history of the tensor's execution) is treated as an 1D array. Numpy-style slicing can be applied to time. For example, the default slicing of `-1` selects the most recent value. However, if the user changes that slicing parameter to `:`, the full history of the tensor will be shown (and the rank of the tensor being visualized is increased by 1). | ||
|
||
# Limitations | ||
# Frequently Asked Questions (FAQ) | ||
|
||
## Q: How to exit the debugging? | ||
|
||
Answer: Follow these steps to interrupt your TensorFlow program being debugged | ||
and the TensorBoard process running the Debugger Plugin (*in that order*): | ||
|
||
1. Send `SIGINT` to the TensorFlow program being debugged, e.g., by using | ||
`Ctrl+C`. | ||
2. Send `SIGINT` to the TensorBoard process running the Debugger Plugin, e.g., | ||
by using `Ctrl+C`. | ||
|
||
# Limitations and Unknown Issues | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: These are known (not unknown) issues. |
||
|
||
The Debugger Plugin has the following limitations and known issues. We plan to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Maybe lowercase debugger plugin to match other uses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
fix them in future releases. | ||
|
||
* Hitting Ctrl+C (issuing a SIGINT signal) might fail to terminate execution for a model that is instrumented with | ||
`TensorBoardDebugWrapperSession` or its corresponding hook. The same limitation may be present in the tensorboard | ||
process as well. In those cases, the user must manually | ||
[kill](https://www.linux.com/learn/intro-to-linux/2017/5/how-kill-process-command-line) the processes. | ||
* The debugger dashboard does not yet support multiple users debugging at once. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe change this phrasing to "debugger plugin" to match other mentions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,11 @@ | |
|
||
import json | ||
import platform | ||
import signal | ||
import sys | ||
import threading | ||
|
||
from six.moves import xrange # pylint:disable=redefined-builtin | ||
import tensorflow as tf | ||
from werkzeug import wrappers | ||
|
||
|
@@ -69,6 +71,7 @@ def __init__(self, context): | |
""" | ||
del context # Unused. | ||
self._debugger_data_server = None | ||
self._server_thread = None | ||
self._grpc_port = None | ||
|
||
def listen(self, grpc_port): | ||
|
@@ -96,8 +99,32 @@ def listen(self, grpc_port): | |
interactive_debugger_server_lib.InteractiveDebuggerDataServer( | ||
self._grpc_port)) | ||
|
||
threading.Thread(target=self._debugger_data_server. | ||
start_the_debugger_data_receiving_server).start() | ||
self._server_thread = threading.Thread( | ||
target=self._debugger_data_server. | ||
start_the_debugger_data_receiving_server) | ||
self._server_thread.start() | ||
|
||
signal.signal(signal.SIGINT, self.signal_handler) | ||
|
||
def signal_handler(self, unused_signal, unused_frame): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be good to note somewhere that this is required because of arguably a deficiency in grpc/python 2.7: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comments. Thanks. |
||
if self._debugger_data_server and self._server_thread: | ||
print('Stopping InteractiveDebuggerPlugin...') | ||
# Enqueue a number of messages to the incoming message queue to try to | ||
# let the debugged tensorflow runtime proceed past the current Session.run | ||
# in the C++ layer and return to the Python layer, so the SIGINT handler | ||
# registered there may be triggered. | ||
for _ in xrange(len(self._debugger_data_server.breakpoints) + 1): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Extra space before 1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
self._debugger_data_server.put_incoming_message(True) | ||
# while True: # DEBUG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get rid of these debug comments? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
try: | ||
self._debugger_data_server.stop_the_debugger_data_receiving_server() | ||
except ValueError: | ||
# In case the server has already stopped running. | ||
pass | ||
# break # DEBUG | ||
self._server_thread.join() | ||
print('InteractiveDebuggerPlugin stopped.') | ||
sys.exit(0) | ||
|
||
def get_plugin_apps(self): | ||
"""Obtains a mapping between routes and handlers. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -524,6 +524,9 @@ def start_the_debugger_data_receiving_server(self): | |
""" | ||
self.run_server() | ||
|
||
def stop_the_debugger_data_receiving_server(self): | ||
self.stop_server() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this alias really necessary? The callsite could just call stop_server() directly, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Removed the |
||
|
||
def SendTracebacks(self, request, context): | ||
self._source_manager.add_graph_traceback(request.graph_version, | ||
request.graph_traceback) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: How to exit debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.