Nextjournal / Nov 05 2019
Tensorboard Environment
Import Tensorflow + Tensorboard docker image, (tensorflow/tensorflow:latest-py3-jupyter
).
TF
Download as Docker image from:
Copy
This image was imported from: tensorflow/tensorflow:latest-py3-jupyter
apt-get install -y git
pip install jupyter jupyter_client \
git+https://github.com/nextjournal/jupyter_core
12.7s
TF+TB (Bash)
TF
restore jupyter connection file permissions if jupyter runtime refuses to start
ls -lah runtimes/jupyter/kernel_connection.json
chmod 600 runtimes/jupyter/kernel_connection.json
ls -lah runtimes/jupyter/kernel_connection.json
0.8s
Fix Permissions (Bash in Python)
Test in Jupyter Runtime
%load_ext tensorboard
0.1s
Jupyter Test (Python 3)
TF+TB
Until we fork tensorboard,
# TODO: fork tensorboard
from IPython.display import publish_display_data
from tensorboard import notebook
import uuid
def _nextjournal_display(port=None,
print_message=False,
display_handle=None):
display_id = str(uuid.uuid4())
print("TENSORBOARD NEXTJOURNAL DISPLAY - %s" % display_id)
data = {"application/vnd.nextjournal.tensorboard+html": "<meta name='nextjournal-display-id' value='%s' />" % display_id}
publish_display_data(data, metadata=None, source=None)
notebook._display = _nextjournal_display
Shift+Enter to run
Jupyter Test (Python 3)
TF+TB
import tensorflow as tf
print("TensorFlow version: ", tf.__version__)
# print(version.parse(tf.__version__))
# %tensorflow_version 2.x
2.5s
Jupyter Test (Python 3)
TF+TB
%tensorboard --logdir logs/train_data --host="0.0.0.0" --port=9998
2.6s
Jupyter Test (Python 3)
TF+TB
Launching TensorBoard...
/runner/Lpxj2cZwiRrLtUsN5rpbp/runtime/runtime-id/5a2cf4f9-166a-4191-87b5-2d354202c4d4
Tensorboard in Nextrepl Runtimes
from tensorboard import notebook
import uuid
class TB(object):
def __init__(self, logdir):
notebook.start("--port 9998 --bind_all --logdir %s" % logdir)
def _repr_mimebundle_(self):
return {'application/vnd.nextjournal.tensorboard+html': "<meta name='nj-display-id' value='%s'/>" % str(uuid.uuid4())}
0.1s
Nextrepl Test (Python)
TF+TB
tb = TB("/train_data/logs")
tb
0.0s
Nextrepl Test (Python)
TF+TB
end