start tensorflow docker container with jupyter and tensorboard together.

Well, today we’re gonna to have new journey on AWS.

I’d like to have some practices of tensorflow on AWS EC2, to make it simple, I decided to use the tensorflow docker image. (You can install tensorflow on EC2 directly, or just use the AWS deep learning AMI, or build the source code of tensorflow if you like)

This is quite simple actually, just pull the docker image and run it, more detail can be found in tensorflow installation page.

Run below command on EC2 instance:

docker run -d -p 8888:8888 gcr.io/tensorflow/tensorflow

then visit http://<EC2 IP>:8888, you can found jupyter is there waiting for you 🙂

NB: Like usually, please make sure you have port 8888 of EC2 instance is reachable from public internet. (add inbound rule of your EC2 security group).

When I played a little with tensorflow, I found that there is no tensorboard I can use, but if I hack into the running docker container, and start tensorboard from command line, it’s there !

So, tensorboard is already in the docker image, but not able to use outside. The point is, according to the design of docker, one container should only have one working process to run (we already have jupyter, so…), but we still can make it possible.

No more bothering, It’s also quite simple, just use ‘docker exec’ command to run tensorboard after jupyter is running.

Here is the scirpt

#!/bin/bash
docker run --name tensorflow \
 -d \
 -v /root/tensorflow/notebooks:/notebooks \
 -v /root/tensorflow/tflogs:/tflogs \
 -e "PASSWORD=tensorflow" \
 -p 8888:8888 \
 -p 6006:6006 \
 gcr.io/tensorflow/tensorflow \


sleep 3

docker exec tensorflow nohup tensorboard --logdir /tflogs &

That’s it ! Now you have your tensorboard at http://<EC2 IP>:6066 waiting for you.

NB: Like usually, please make sure you have port 6006 of EC2 instance is reachable from public internet. (add inbound rule of your EC2 security group).

Let’s have fun with tensorflow on EC2.

Leave a Reply

Your email address will not be published. Required fields are marked *