Implement liveness check for notebook extensions
See original GitHub issueCurrently, each TensorBoard process writes its meta-information to a
file in the shared .tensorboard-info
temp directory, and tries to
clean up the file on graceful exit. This has two problems on Windows:
- The base temporary directory
%TMP%
is never automatically cleaned, even after logout or reboot. - It is not possible to gracefully shut down an arbitrary process given its PID.
The result is that most any TensorBoards started by %tensorboard
will
leave their info files around forever, unless manually cleaned up, and
the instructions suggested to the user (“use !kill …
”) are not
adequate to effect this cleanup. See #2481.
We can ameliorate this by implementing the liveness check mentioned in a
TODO in manager.py
, cleaning up the dead info file on failure:
We can also provide a notebook.kill(pid)
function with implementation
something vaguely like
def kill(pid):
if os.name == "nt":
subprocess.check_output(["taskkill", "/pid", str(int(pid)), "/f"])
manager.remove_info_file(pid)
else:
os.kill(pid, signal.SIGTERM)
and then replace the “reusing TensorBoard” user-facing messaging on Windows with something like
template = (
"Reusing TensorBoard on port {port} (pid {pid}), started {delta} ago. "
"To kill it, run `from tensorboard import notebook; notebook.kill({pid})`."
)
though that incantation still is a bit of a mouthful.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
For those on Windows trying to do this from Jupyter, the following two commands will automate the process. You can just toss them in a cell and run them after you are done with the open TensorBoard instance (or before you need to check a different log file).
Same issues: TensorBoard is not reliable within Jupyter. Based on this thread I did the following with marginal success. TensorBoard was good for only one time after the cleanup.