How do I use TensorBoard on a cloud GPU?

Write your training metrics to a log folder (with PyTorch, SummaryWriter writes to ./runs/ by default), run tensorboard --logdir runs on the instance, then run ssh -N -L 6006:127.0.0.1:6006 -p <ssh-port> <ssh-user>@<ssh-host> on your own computer and open http://localhost:6006; according to the official TensorBoard README, TensorBoard 2.0 and up listens on localhost by default, so the tunnel lets you see it without opening the port to the internet.
Updated 2026-10-28
This guide follows the official PyTorch recipe How to use TensorBoard with PyTorch, the torch.utils.tensorboard API docs, the TensorBoard README and the tensorboard package page on PyPI, all read on 2026-10-28. TensorBoard is a visualization toolkit for machine learning experiments, released under the Apache-2.0 license. This guide is for people who train on a rented NVIDIA GPU such as the RTX 5090 or the other NVIDIA cards listed on /pricing and want to watch loss curves from their own browser.
Step 1: Deploy a Raw GPU and connect
On /deploy, pick an NVIDIA GPU and the Raw GPU option (JupyterLab + CUDA pre-installed, root SSH). Note the SSH host, port and user from your dashboard; you need them again in Step 5. Connect over SSH or open a terminal in JupyterLab.
VRAM need depends on model, precision and workflow; see How much VRAM do I need to run an LLM?. TensorBoard itself only reads log files, so the card you choose is about your training job, not about TensorBoard.
Step 2: Check the environment first
nvidia-smi # GPU name, driver version and the "CUDA Version" the driver supports
nvcc --version # CUDA toolkit compiler, if installed
python3 --version # PyPI lists Python 3.9 or newer for the tensorboard package
python3 -c "import torch; print(torch.__version__, torch.cuda.is_available())"
What to look for:
nvidia-smishould list your GPU. Your training job needs a PyTorch build that matches the driver’s CUDA Version; iftorch.cuda.is_available()printsFalseor PyTorch is missing, see How to install a specific PyTorch CUDA version on a cloud GPU.- Python. The tensorboard package on PyPI (version 2.21.0 on 2026-10-28) requires Python 3.9 or newer. Install it in the same environment as your training code; see How to set up a conda environment on a cloud GPU if you keep separate environments.
Step 3: Log metrics from your training script
According to the official PyTorch recipe, create a SummaryWriter, log values with add_scalar, and call flush() so pending events are written to the log file:
import torch
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter() # writes to ./runs/ by default
x = torch.arange(-5, 5, 0.1).view(-1, 1)
y = -5 * x + 0.1 * torch.randn(x.size())
model = torch.nn.Linear(1, 1)
criterion = torch.nn.MSELoss()
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
def train_model(iter):
for epoch in range(iter):
y1 = model(x)
loss = criterion(y1, y)
writer.add_scalar("Loss/train", loss, epoch)
optimizer.zero_grad()
loss.backward()
optimizer.step()
train_model(10)
writer.flush()
writer.close()
Two tips from the torch.utils.tensorboard docs:
- One folder per run. The default
log_dirisruns/CURRENT_DATETIME_HOSTNAME, which changes after each run. To compare experiments, the docs suggest passingruns/exp1,runs/exp2and so on, for exampleSummaryWriter("runs/exp1"). - Group charts with slashes. Tags such as
Loss/trainandLoss/testare grouped together in the TensorBoard interface.
Step 4: Start TensorBoard on the instance
Install TensorBoard and point it at the log folder, as the PyTorch recipe shows:
pip install tensorboard
tensorboard --logdir runs --port 6006
The recipe says TensorBoard “will recursively walk the directory structure rooted at logdir, looking for .tfevents. files”, so --logdir runs picks up every run inside runs/. Run it in its own tmux or screen window (check with which tmux screen) so it keeps running while you train and if your SSH session drops; see How to check GPU utilization on a cloud GPU for watching the GPU in another window.
Leave the host setting alone. The TensorBoard README says that in TensorBoard 2.0 and up --host localhost is the default, and that --bind_all serves “to the public network on both IPv4 and IPv6”. The SSH tunnel in the next step works with the localhost default, so you do not need --bind_all.
Step 5: Open TensorBoard in your browser through SSH
Run this on your computer, in a new terminal, not on the instance:
ssh -N -L 6006:127.0.0.1:6006 -p <ssh-port> <ssh-user>@<ssh-host>
The terminal stays open and prints nothing; that is the tunnel running. Open http://localhost:6006 in your browser (the README names Google Chrome and Firefox). Press Ctrl+C to close the tunnel. If port 6006 is already used on your computer, use -L 16006:127.0.0.1:6006 and open http://localhost:16006. How to use SSH port forwarding on a cloud GPU explains each flag and how to save the tunnel in ~/.ssh/config.
Step 6: If the dashboard is empty
The TensorBoard README’s FAQ gives these checks, run on the instance:
# is there at least one event file under the log folder?
find runs | grep tfevents
# do the event files contain data?
tensorboard --inspect --logdir runs
Other causes to rule out:
- Wrong folder.
--logdirmust point at the folder your script writes to. A relative path likerunsis resolved from the directory where you start each command. - Events not written yet. Call
writer.flush()during long runs, orwriter.close()at the end, as the PyTorch recipe shows. - Port already taken on the instance. Start TensorBoard with
--port 6007and change the right-hand side of the tunnel to127.0.0.1:6007.
Step 7: Save your logs, then destroy the instance
Data on the instance is deleted when you destroy it, so copy your runs/ folder, checkpoints and configs to your computer first, for example from your computer:
scp -P <ssh-port> -r <ssh-user>@<ssh-host>:~/runs ./runs
You can then run tensorboard --logdir runs on your own computer to look at the same charts later. GPU time is billed per minute, rounded up, with a 1-minute minimum, and billing stops when you destroy the instance; see /terms.
FAQ
How do I open TensorBoard running on a cloud GPU?
Start tensorboard --logdir runs on the instance, then run ssh -N -L 6006:127.0.0.1:6006 -p
Do I need --bind_all to see TensorBoard from my computer?
No. The official TensorBoard README says --host localhost is the default in TensorBoard 2.0 and up, and that --bind_all serves to the public network on both IPv4 and IPv6. An SSH tunnel reaches TensorBoard on localhost, so the default setting is enough.
Where does PyTorch save TensorBoard logs?
According to the official PyTorch docs, SummaryWriter writes to the ./runs/ directory by default, in a subfolder named runs/CURRENT_DATETIME_HOSTNAME that changes after each run. Pass a name such as runs/exp1 to keep each experiment in its own folder.
Why is my TensorBoard dashboard empty?
The TensorBoard README suggests checking that --logdir points at the right folder, that find DIRECTORY_PATH | grep tfevents shows at least one event file, and that tensorboard --inspect --logdir DIRECTORY_PATH shows data. In PyTorch, call writer.flush() so pending events are written to the log file.
How is a Raw GPU billed while TensorBoard is open?
GPU time is billed per minute, rounded up, with a 1-minute minimum, and billing stops when you destroy the instance. See https://cloudgpu.app/terms for the full terms.