torchviz
A small package to create visualizations of PyTorch execution graphs
What it is and what it does
torchviz is a small visualization utility for PyTorch that converts neural network computation graphs into diagrams. It takes a PyTorch tensor output and the model's parameters, then uses graphviz to render a visual representation of how data flows through the network's layers and operations during the forward pass. The package can optionally display what autograd saves for the backward pass (available for PyTorch 1.9 and later) by setting `show_attrs=True` and `show_saved=True`.
The package is designed for model inspection and debugging—developers use it to understand network architecture visually, verify layer connections, and trace tensor transformations. It depends on torch for the computation graph structure and graphviz for rendering the diagram as an image or PDF. Installation requires both the Python package and the graphviz system library.
Use it for:
- Visualize a custom neural network architecture to verify layer connections and data flow during forward pass.
- Debug autograd computation graphs to understand which operations are tracked for backpropagation.
- Generate architecture diagrams for documentation or research papers showing model structure.
- Inspect what intermediate tensors and gradients are saved during the forward pass for memory analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates visual diagrams of PyTorch neural network computation graphs and autograd traces, showing layer connections and tensor flow through the model.
Yes, if you need to visualize PyTorch computation graphs for debugging or documentation. The install is straightforward and the package has no known vulnerabilities. However, maintenance is dormant (620 days since last release), so verify compatibility with your PyTorch version before relying on it for production workflows. The graphviz system dependency is a minor friction point but standard for graph visualization.
Install
torchviz on PyPI
pip
pip install torchvizuv
uv add torchvizpoetry
poetry add torchvizInstalling torchviz
Before you install
Low friction install with a pure Python wheel, but depends on the graphviz system library which must be installed separately. Maintenance is dormant—last release was 620 days ago, though the package remains in the top 5000 by downloads.
License in practice
BSD permissive license allows use in most projects without restriction, including commercial and proprietary software.
Quickstart
pip install torchviz
from torchviz import make_dot
import torch
from torch import nn
model = nn.Sequential(nn.Linear(8, 16), nn.Tanh(), nn.Linear(16, 1))
x = torch.randn(1, 8)
y = model(x)
make_dot(y.mean(), params=dict(model.named_parameters()))
graphviz system library must be installed separately (e.g., `brew install graphviz` on macOS).
Verify before relying
- Whether the package works with recent PyTorch versions given 620 days since last release.
- Current status of the GitHub repository and whether it is actively maintained by PyTorch maintainers.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — torch, graphviz |
| Maintenance | dormant — 620 days since the last release |
| First released | |
| Downloads | 2,052,967/month — #3,338 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: torchviz-0.0.3-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
pygraphvizPyGraphviz provides a Python interface to…
permissive · top 5,000 on PyPI
pydotplusPyDotPlus provides a Python interface to…
permissive · top 15,000 on PyPI
gravisGravis generates interactive graph…
permissive · top 15,000 on PyPI
torchsummaryDisplays a Keras-style summary of PyTorch…
unclear · top 15,000 on PyPI
graphvizGenerates DOT language source code for graph…
permissive · top 1,000 on PyPI
pystructurizrPyStructurizr provides a Python DSL for…
permissive · top 15,000 on PyPI
diagramsDiagrams lets you draw cloud system…
permissive · top 5,000 on PyPI
torch-geometricPyTorch Geometric is a library for building and…
permissive · top 5,000 on PyPI
tinygradtinygrad is a minimal deep learning framework…
permissive · top 15,000 on PyPI