OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Torchview

Torchview is an MIT-licensed Python library that visualizes PyTorch models as Graphviz computation graphs, including modules, tensors, operations and input/output shapes.

Independent OpenViST project profile, based on linked sources.

Torchview — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Torchview when a PyTorch model’s structure or forward computation is easier to inspect as a diagram than from its code alone.

Who it is for

  • Python developers inspecting the structure of PyTorch models.
  • Machine-learning practitioners documenting or exploring model architecture and computation flow.

Documented uses

  • Turn a PyTorch model’s forward computation into a visual graph.
  • Inspect module hierarchy, tensor operations and input/output shapes.
  • Adjust diagram detail with options for graph depth, nested modules and rolling recursively used modules.
Before you choose

Requirements & limits

Torchview is distributed as a Python library through uv, pip and conda, and its repository identifies an MIT license.

  • The documented interface supports PyTorch 1.7 and later; meta-tensor support requires PyTorch 1.13 or later.
  • Graphviz must be installed, and its dot layout command must be available to the Python interface.
  • The function accepts either input data or input sizes, with dtypes needing to match the model input.
  • Large SVG output may be cropped in VS Code; the README suggests PNG rendering as a workaround.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Create a PyTorch model graph

Generate a Graphviz visualization of a PyTorch model using Torchview’s documented Python interface.

Before you start

  • Python 3.9 or later
  • PyTorch 1.7 or later
  • Torchview and the Graphviz Python package
  • The Graphviz dot layout command available on the system
  • A PyTorch model and its input size or input data

Steps

  1. Install Graphviz and ensure the system dot command is available.

  2. Install Torchview with uv, pip or conda.

  3. Import draw_graph and pass it a model and input description, for example draw_graph(model, input_size=(2, 128), device='meta').

  4. Access the returned graph’s visual_graph property.

Expected outcome

A Graphviz model diagram that can show module structure, tensor operations and input/output shapes.

Guide limitations

  • Meta-device visualization requires PyTorch 1.13 or later.
  • The model’s input description must match its expected input types and dimensions.
  • The README reports that large SVG graphs can be cropped in VS Code and suggests PNG rendering in that environment.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
13 October 2026
Original website title
mert-kurttutan/torchview · Official homepage title · retained in its source language