Search code examples
google-cloud-platformtensorboard

Tensorboard - can't connect from Google Cloud Instance


I'm trying to load Tensorboard from within my google cloud VM terminal.

tensorboard --logdir logs --port 6006

Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all TensorBoard 2.2.1 at http://localhost:6006/ (Press CTRL+C to quit)

When I click on the link:

Chrome I get error 400

Firefox Error: Could not connect to Cloud Shell on port 6006. Ensure your server is listening on port 6006 and try again.

I've added a new firewall rule to allow port 6006 for ip 0.0.0.0/0 , but still can't get this to work. I've tried using --bind_all too but this doesn't work.


Solution

  • For anyone else struggling with this, I decided to output my logs to an S3 bucket, and then rather than trying to run tensorboard from within the GCP instance, I just ran it locally, tested with the below script.

    I needed to put this into a script rather than calling directly from the command line as I needed my AWS credentials to be loaded. I then use subprocess to run the command line function as normal.

    Credentials contained within an env file, found using python-dotenv

    from dotenv import find_dotenv, load_dotenv
    import subprocess
    load_dotenv(find_dotenv())
    
    
    if __name__=='__main__':
        cmd = 'tensorboard --logdir s3://path-to-s3-bucket/Logs/'
        p = subprocess.Popen(cmd, shell=True)
        p.wait()
    
    
    
    Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
    TensorBoard 2.1.1 at http://localhost:6006/ (Press CTRL+C to quit)
    

    enter image description here