{"id":810,"library":"tensorboard","title":"TensorBoard","description":"TensorBoard is a powerful visualization toolkit for machine learning experimentation, enabling tracking of metrics like loss and accuracy, visualization of model graphs, projection of embeddings, and much more. It is closely integrated with TensorFlow and PyTorch ecosystems, and its releases generally track TensorFlow versions. The current stable version is 2.20.0, and it is actively maintained with regular updates.","status":"active","version":"2.20.0","language":"python","source_language":"en","source_url":"https://github.com/tensorflow/tensorboard","tags":["machine-learning","deep-learning","visualization","tensorflow","pytorch"],"install":[{"cmd":"pip install tensorboard","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Added as a dependency in 2.20.0 to replace the deprecated `imghdr` standard library module, ensuring compatibility with Python 3.13 and newer.","package":"Pillow","optional":false},{"reason":"TensorBoard has historically had specific requirements or restrictions on `protobuf` versions. While often relaxed, users should be aware of potential conflicts if other libraries pin `protobuf` to an incompatible version.","package":"protobuf","optional":false},{"reason":"Compatibility updates for `numpy` 2.0 were introduced in TensorBoard 2.18.0 and 2.17.1 to ensure proper functioning.","package":"numpy","optional":false},{"reason":"The dependency on `tf-keras` (and `tf-keras-nightly` previously) was removed in TensorBoard 2.16.2. While not a direct dependency, Keras versions can impact plugin compatibility.","package":"tf-keras","optional":true},{"reason":"These libraries were removed as direct dependencies in TensorBoard 2.16.0. Users requiring their functionality in their own code should install them explicitly.","package":"google-auth, google-auth-oauthlib, requests","optional":true}],"imports":[{"note":"Commonly used for logging data from PyTorch models.","symbol":"SummaryWriter","correct":"from torch.utils.tensorboard import SummaryWriter"},{"note":"Used to integrate TensorBoard logging with Keras `Model.fit()`.","symbol":"TensorBoard callback for Keras","correct":"from tensorflow.keras.callbacks import TensorBoard"},{"note":"For low-level summary logging in TensorFlow 2.x without Keras callbacks.","symbol":"tf.summary","correct":"import tensorflow as tf\nwriter = tf.summary.create_file_writer('logs/my_experiment')"}],"quickstart":{"code":"import datetime\nfrom torch.utils.tensorboard import SummaryWriter\n\nlog_dir = \"runs/\" + datetime.datetime.now().strftime(\"%Y%m%d-%H%M%S\")\nwriter = SummaryWriter(log_dir)\n\n# Log a scalar value\nfor i in range(100):\n    writer.add_scalar('Loss/train', 100 / (i + 1), i)\n    writer.add_scalar('Accuracy/train', i / 100, i)\nwriter.close()\n\nprint(f\"TensorBoard logs saved to: {log_dir}\")\nprint(\"To view, run in your terminal: tensorboard --logdir runs\")","lang":"python","description":"This example demonstrates how to use `SummaryWriter` from `torch.utils.tensorboard` to log scalar values, creating event files in a timestamped directory. After running the script, you can launch TensorBoard from your terminal to visualize the logged data."},"warnings":[{"fix":"Migrate to self-hosting TensorBoard or alternative experiment tracking platforms. There is no direct replacement for `tensorboard.dev` functionality within TensorBoard itself.","message":"TensorBoard.dev, the hosted sharing service, has been shut down. The `tensorboard dev upload` command will fail and the website is no longer accessible.","severity":"breaking","affected_versions":">=2.15.1"},{"fix":"Monitor official releases and documentation for Keras 3 compatibility updates. If issues arise, consider running Keras 2 compatible environments or alternative debugging strategies.","message":"TensorBoard plugin compatibility with Keras 3. While TensorFlow 2.16+ uses Keras 3 by default, some TensorBoard plugins' implementations may still primarily support Keras 2. This can lead to unexpected behavior or missing visualizations for Keras 3 models.","severity":"gotcha","affected_versions":">=2.16.0"},{"fix":"Ensure `protobuf` version is compatible with your TensorBoard installation. Use `pip check` to find conflicts and consider creating isolated virtual environments. If problems persist, try reinstalling `tensorboard` which often pulls a compatible `protobuf` version.","message":"Protobuf dependency conflicts can occur. TensorBoard's `protobuf` requirements have varied across versions (e.g., tight restrictions, then relaxations). This can cause installation errors or runtime issues if other installed libraries have conflicting `protobuf` version requirements.","severity":"gotcha","affected_versions":"All versions (historically problematic around 2.15.x - 2.18.x)"},{"fix":"Upgrade TensorBoard to version 2.20.0 or newer if using Python 3.13.","message":"Python 3.13 compatibility requires TensorBoard version 2.20.0 or higher. Earlier versions will fail on Python 3.13 due to the removal of the `imghdr` module from the standard library, which TensorBoard previously used.","severity":"gotcha","affected_versions":"<2.20.0 on Python 3.13"},{"fix":"Always explicitly call `writer.flush()` and `writer.close()` at the end of your logging session, or use `with SummaryWriter(...) as writer:` context manager.","message":"When using `SummaryWriter` in notebook environments (e.g., Colab, Jupyter), it's highly recommended to call `writer.flush()` and `writer.close()` after logging data. This ensures all event files are properly written to disk and available for TensorBoard to render, preventing data loss or incomplete visualizations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install PyTorch. This can typically be done via pip: `pip install torch` or by following the specific installation instructions on the PyTorch website (e.g., `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118` for CUDA-enabled versions).","message":"When attempting to import `torch.utils.tensorboard.SummaryWriter`, a `ModuleNotFoundError: No module named 'torch'` indicates that the PyTorch library is not installed or not accessible in the environment. The `torch.utils.tensorboard` module is part of PyTorch and explicitly requires a PyTorch installation.","severity":"breaking","affected_versions":"All versions (where `torch.utils.tensorboard` is used)"},{"fix":"Ensure `torch` is installed in your environment. For example, `pip install torch` (or specify a specific version/platform as per PyTorch installation instructions). If using `torch.utils.tensorboard`, `tensorboard` itself also needs to be installed via `pip install tensorboard`.","message":"The `torch` library is a required dependency when using `torch.utils.tensorboard.SummaryWriter`. If `torch` is not installed, a `ModuleNotFoundError` will occur.","severity":"breaking","affected_versions":"All versions using `torch.utils.tensorboard`"}],"env_vars":null,"last_verified":"2026-05-12T19:41:22.970Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"pip install tensorboard","cause":"The `tensorboard` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'tensorboard'"},{"fix":"Activate your virtual environment (e.g., `source venv/bin/activate`) or try running `python -m tensorboard.main --logdir=/path/to/logs`.","cause":"The `tensorboard` executable is not in the system's PATH, often due to an inactive virtual environment or an incomplete installation.","error":"tensorboard command not found"},{"fix":"For PyTorch, import `SummaryWriter` from `torch.utils.tensorboard`: `from torch.utils.tensorboard import SummaryWriter`.","cause":"PyTorch users incorrectly attempt to import `SummaryWriter` directly from the `tensorboard` package instead of `torch.utils.tensorboard`.","error":"ImportError: cannot import name 'SummaryWriter' from 'tensorboard'"},{"fix":"Start TensorBoard on a different port using the `--port` argument: `tensorboard --logdir=./runs --port 6007`.","cause":"The default port (6006) or a specified port that TensorBoard tries to use is already occupied by another process.","error":"OSError: [Errno 98] Address already in use"},{"fix":"Verify that the `logdir` path correctly points to the directory containing your event files, ensure your training script is actively writing summary data, and call `writer.flush()` to ensure data is written to disk.","cause":"This message appears in the TensorBoard UI when the `logdir` path provided is incorrect, empty, or does not contain any valid event files that TensorBoard can parse.","error":"No dashboards are active for the current data set."}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.20.0","cli_name":"tensorboard","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"146.5M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":7.3,"import_time_s":null,"mem_mb":null,"disk_size":"160M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"156.9M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":6.6,"import_time_s":null,"mem_mb":null,"disk_size":"170M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"153.7M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":6.6,"import_time_s":null,"mem_mb":null,"disk_size":"167M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"153.2M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":6.6,"import_time_s":null,"mem_mb":null,"disk_size":"166M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"152.5M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":8.7,"import_time_s":null,"mem_mb":null,"disk_size":"169M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}