View Tensorboard on Docker in Google Cloud

I am trying to map TensorBoard from TensorFlow to Docker in Google Cloud.

http://tensorflow.org/how_tos/summaries_and_tensorboard/index.md

tensorboard --logdir ./

I have Apache running on Google Cloud (this may be in my first container โ€œai-unicorn.โ€ โ€œDockerโ€ created its own โ€œdocker platformโ€ for containers). I see the default page from Google Cloud at http://104.197.119.57/ .

I run TensorBoard on Google Cloud as follows:

root@6cf64fd299f0 :/# tensorboard --logdir ./ Starting TensorBoard on port 6006 (You can navigate to http://localhost:6006)

I tried the Google Cloud SSH option called "Open in a browser window on a user port" using port 6006.

Displayed: "We cannot connect to the VM on port 6006."

What is the right way to view TensorBoard from Google Cloud?

+4
docker tensorflow google-cloud-platform tensorboard
source share
3 answers

By default , TensorBoard serves requests at 127.0.0.1 , which is only available for processes running on the same computer. If you start TensorBoard using --host 0.0.0.0 , it will also serve requests on remote interfaces, so you can connect to it remotely:

 $ tensorboard --logdir ./ --host 0.0.0.0 

Please note that โ€œOpen in the browser window on the user portโ€ will not connect to the TensorBoard server - this parameter is used to connect to the SSH server on a non-standard port. The Google Cloud Platform docs contain information on how to set ports from your virtual machine. For remote access to your virtual machine, you need to allow connections to TCP port 6006. You may also need to open port 6006 from your Docker container, following the instructions here .

EDIT: Added some step-by-step instructions to help you configure Docker. There are several problems here, and it is not possible to determine which one is faulty.

  • Configure port forwarding when starting the Docker container:

     (vm)$ docker run -p 0.0.0.0:7007:6006 -it b.gcr.io/tensorflow/tensorflow 

    This translates the connections from port 7007 on your virtual machine to 6006 into a Docker container. (Other values โ€‹โ€‹are possible.)

  • Make sure you can connect to the TensorBoard from the Docker container:

     (container)$ tensorboard --logdir ./ --host 0.0.0.0 --port 6006 & (container)$ curl http://localhost:6006/ 

    The second command should print some HTML in the console.

  • In the shell on the virtual machine, make sure that you can connect to the TensorBoard instance running in the container:

     (vm)$ curl http://localhost:7007/ 

    The command should print the same HTML code to the console.

  • Configure the Google Cloud firewall so that the local client can connect to port 7007 on your virtual machine.

     (client)$ gcloud compute firewall-rules create tensorboard --allow tcp:7007 

    Now you can connect to TensorBoard in a web browser on your client.

+14
source share

You do not need to use Docker to display TensorBoard. But if you want to use Docker, just launch TensorBoard inside your Docker image.

The trick is to allow external access to the Tcp port 6006 of TensorBoard by default.

I tried the following working solution for displaying TensorBoard in my Google Virtual Machine.

  • make sure you pass gcloud authentication:

    gcloud auth login

  • allow public access to tcp 6006 port

    gcloud computes firewall rules, creates tensor port --allow tcp: 6006

  • Launch TensorBoard on Your Virtual Machine

    tensorboard --logdir = workspace / train /

  • Use an external IP address to access TensorBoard from outside your virtual machine:

    Open the address http: // your_vm_external IP: 6006 /,

    eg. http://104.196.140.145:6006/ , where 104.196.140.145 is the external IP address of my virtual machine.

Enjoy TensorBoard

+2
source share

another option is to use ngrok for the tunnel. see Can I use Tensorboard with Google Colab?

 $ from jupyter notebook ps = !ps -ax is_tensorboard_running = len([f for f in ps if "tensorboard" in f ]) > 0 is_ngrok_running = len([f for f in ps if "ngrok" in f ]) > 0 print("tensorbord={}, ngrok={}".format(is_tensorboard_running, is_ngrok_running)) if not is_ngrok_running: # grok should be installed in /content/ngrok get_ipython().system_raw('/content/ngrok http 6006 &') is_ngrok_running = True # get public url for tensorboard tensorboard_url = !curl -s http://localhost:4040/api/tunnels | python3 -c \ "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])" print("tensorboard url=", tensorboard_url) 
+1
source share

All Articles