Jacky Liu
Jacky Liu

Reputation: 147

How to run Tensorboard and jupyter concurrently with docker?

I'm starting to learn how to use TensorFlow to do machine learning. And find out docker is pretty convenient to deploy TensorFlow to my machine. However, the example that I could found did not work on my target setting. Which is

Under ubuntu16.04 os, using nvidia-docker to host jupyter and tensorboard service together(could be two container or one container with two service). And files create from jupyter should be visible to host OS.

Jupyter container

nvidia-docker run \
    --name jupyter \
    -d \
    -v $(pwd)/notebooks:/root/notebooks \
    -v $(pwd)/logs:/root/logs \
    -e "PASSWORD=*****" \
    -p 8888:8888 \
    tensorflow/tensorflow:latest-gpu 

Tensorboard container

nvidia-docker run \
    --name tensorboard \
    -d \
    -v $(pwd)/logs:/root/logs \
    -p 6006:6006 \
    tensorflow/tensorflow:latest-gpu \
    tensorboard --logdir /root/logs

I tried to mount logs folder to both container, and let Tensorboard access the result of jupyter. But the mount seems did work. When I create new file in jupyter container with notebooks folder, host folder $(pwd)/notebooks just appear nothing.

I also followed the instructions in Nvidia Docker, Jupyter Notebook and Tensorflow GPU

nvidia-docker run -d -e PASSWORD='winrar' -p 8888:8888 -p 6006:6006 gcr.io/tensorflow/tensorflow:latest-gpu-py3

Only Jupyter worked, tensorboard could not reach from port 6006.

Upvotes: 7

Views: 6019

Answers (2)

Lukas Masuch
Lukas Masuch

Reputation: 564

As an alternative, you can also use the ML Workspace Docker image. The ML Workspace is a web IDE that combines Jupyter, TensorBoard, VS Code, and many other tools & libraries into one convenient Docker image. Deploying a single workspace instance is as simple as:

docker run -p 8080:8080 mltooling/ml-workspace:latest

All tools are accessible from the same port. You can find information on how to access TensorBoard here.

Upvotes: 0

Iyán
Iyán

Reputation: 101

I was facing the same problem today.

Short answer: I'm going to assume you are using the same container for both Jupyter Notebook and tensorboard. So, as you wrote, you can deploy the container with:

nvidia-docker run -d --name tensor -e PASSWORD='winrar'\
                  -p 8888:8888 -p 6006:6006 gcr.io/tensorflow/tensorflow:latest-gpu-py3

Now you can access both 8888 and 6006 ports but first you need to initialize tensorboard:

docker exec -it tensor bash
tensorboard --logdir /root/logs

About the other option: running jupyter and tensorboard in different containers. If you have problems mounting same directories in different containers (in the past there was a bug about that), since Docker 1.9 you can create independent volumes unlinked to particular containers. This may be a solution.

  1. Create two volumes to store logs and notebooks.
  2. Deploy both images with these volumes.

docker volume create --name notebooks
docker volume create --name logs 

nvidia-docker run \
--name jupyter \
-d \
-v notebooks:/root/notebooks \
-v logs:/root/logs \
-e "PASSWORD=*****" \
-p 8888:8888 \
tensorflow/tensorflow:latest-gpu

 nvidia-docker run \
 --name tensorboard \
 -d \
 -v logs:/root/logs \
 -p 6006:6006 \
 tensorflow/tensorflow:latest-gpu \
 tensorboard --logdir /root/logs

Upvotes: 7

Related Questions