Skip to main content

Real-time Torch visualization window with Vulkan zero-copy

Project description

๐Ÿ”ฅ Vultorch

Real-time Torch Visualization Window ยท Vulkan Zero-Copy

Visualize CUDA tensors at GPU speed โ€” zero CPU readback, zero staging buffers.

License: MIT Python 3.8+ Vulkan

๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡ ยท ๐ŸŒ Website


Vultorch screenshot

Overview

Vultorch displays CUDA tensors in a native window โ€” data never leaves the GPU. show() performs a fast GPU-GPU copy; create_tensor() eliminates even that via Vulkan shared memory.

vultorch.show(tensor)           # GPU-only, no CPU readback
tensor = vultorch.create_tensor(...)  # true zero-copy, no memcpy at all

Key Features

  • GPU-only display โ€” vultorch.show(tensor) does a fast GPU-GPU copy to Vulkan, no CPU readback ever
  • True zero-copy โ€” vultorch.create_tensor() returns a torch.Tensor backed by Vulkan shared memory โ€” zero memcpy
  • Declarative API โ€” View โ†’ Panel โ†’ Canvas with auto layout and per-frame callback support
  • Built-in ImGui โ€” Sliders, buttons, color pickers, plots, docking layout โ€” all from Python
  • 3D scene view โ€” Map textures onto lit 3D planes with orbit camera, MSAA, Blinn-Phong shading
  • Docking windows โ€” Drag-and-drop window arrangement (ImGui docking branch)

Quick Start

pip install vultorch
import torch, vultorch

# Your neural texture output (or any CUDA tensor)
texture = torch.rand(512, 512, 4, device="cuda")

view = vultorch.View("Neural Texture Viewer", 800, 600)
panel = view.panel("Output")
panel.canvas("main").bind(texture)
view.run()

True Zero-Copy

# Shared GPU memory โ€” writes are instantly visible on screen
tensor = vultorch.create_tensor(512, 512, channels=4)
tensor[:] = model(input)   # write directly, no copy needed

3D Scene

scene = vultorch.SceneView("3D", 800, 600, msaa=4)
scene.set_tensor(texture)
scene.render()  # orbit camera, Blinn-Phong lighting

Examples

Example Description
01_hello_tensor.py Minimal tensor display
02_imgui_controls.py Multi-panel layout with docking
03_training_test.py Tiny network live training (GT vs prediction + bottom info panel)
python examples/01_hello_tensor.py

Building from Source

Prerequisites

Component Required Notes
GPU โœ… Any Vulkan-capable GPU (NVIDIA, AMD, Intel)
Vulkan SDK โœ… Build lunarg.com/vulkan-sdk โ€” headers + glslangValidator
Vulkan driver โœ… Runtime Ships with your GPU driver
CUDA Toolkit Optional Enables GPU zero-copy in show() / create_tensor()
Python 3.8+ โœ… With development headers (python3-dev on Linux)
CMake 3.25+ โœ… Build

Step 1 โ€” Clone (with submodules)

git clone --recursive https://github.com/ChenlizheMe/Vultorch.git
cd Vultorch

If you forgot --recursive, run: git submodule update --init --recursive

Step 2 โ€” Configure

Choose the preset matching your platform:

# Windows (MSVC)
cmake --preset release-windows

# Linux / WSL2 (GCC + Make)
cmake --preset release-linux

CMake automatically detects your active Python interpreter and CUDA toolkit (if installed).

Step 3 โ€” Build

cmake --build --preset release-windows    # or release-linux

This executes three targets in order:

  1. _vultorch โ€” Compiles the C++ extension module (.pyd / .so) and SPIR-V shaders.
  2. package_wheel โ€” Runs tools/make_wheel.py to produce a pip-installable .whl in dist/.
  3. docs (optional) โ€” If mkdocs is installed, builds tutorial + API docs into docs/tutorial/.

Step 4 โ€” Install

pip install dist/vultorch-*.whl

Verify:

python -c "import vultorch; print(vultorch.__version__, 'CUDA:', vultorch.HAS_CUDA)"

WSL2 Quick Setup

A one-command setup script for Ubuntu WSL2:

sudo bash scripts/setup_wsl2.sh

This installs all system dependencies (CMake, Vulkan headers, SDL2 dev libs, Python dev).


Packaging

Single Wheel

The build already produces a wheel in dist/. You can also manually run:

python tools/make_wheel.py

This reads the compiled _vultorch.*.pyd / .so from vultorch/, bundles it with the Python package files, and outputs a platform-specific .whl to dist/.

Multi-Version Wheels

Build wheels for multiple Python versions (requires conda):

# All default versions (3.8 โ€“ 3.12)
python scripts/build_wheels.py

# Specific versions
python scripts/build_wheels.py 3.10 3.11 3.12

Each version gets a separate conda environment; CMake is re-configured and rebuilt for each.

Upload to PyPI

# Interactive token prompt
python scripts/upload_wheels.py

# Pass token directly
python scripts/upload_wheels.py --token pypi-YOUR_TOKEN

Requires twine (auto-installed if missing).


Testing

Tests use pytest with two custom markers:

Marker Description
gpu Requires a Vulkan-capable GPU with CUDA
slow Long-running tests

Run All Tests

pytest

Run Only Non-GPU (Pure Python) Tests

pytest -m "not gpu"

Run GPU Tests Only

pytest -m gpu

Run with Verbose Output

pytest -ra -v

Test Structure

File Scope
tests/conftest.py Shared fixtures + skip decorators
tests/test_import.py Package import, version, module structure
tests/test_camera_light.py Camera / Light data classes
tests/test_normalize_tensor.py _normalize_tensor() dtype, shape, contiguity
tests/test_show.py show() / create_tensor() error paths
tests/test_declarative_api.py Canvas / Panel / View / RowContext (non-GPU)
tests/test_edge_cases.py Edge-case and error-path coverage
tests/test_ui_bindings.py All vultorch.ui.* functions exist
tests/test_project_structure.py Type stubs, configs, examples, tutorials
tests/test_tools_spv_to_header.py tools/spv_to_header.py
tests/test_tools_make_wheel.py tools/make_wheel.py
tests/test_scripts.py scripts/build_wheels.py + upload_wheels.py
tests/test_gpu_integration.py GPU: Window, show(), create_tensor(), SceneView, ImGui
tests/test_engine_bindings.py GPU: C++ Engine class bindings
tests/test_panel_widgets_gpu.py GPU: Panel widgets + Canvas in real render loop

Documentation

Tutorial & API Reference

Documentation is built with MkDocs Material and the i18n plugin (English + Chinese). Source files live in tutorial/:

tutorial/
โ”œโ”€โ”€ index.md / index.zh.md          # Home page
โ”œโ”€โ”€ 01_hello_tensor.md / .zh.md     # Tutorial: Hello Tensor
โ”œโ”€โ”€ 02_multi_panel.md / .zh.md      # Tutorial: Multi-Panel
โ”œโ”€โ”€ 03_training_test.md / .zh.md    # Tutorial: Training Test
โ””โ”€โ”€ api.md / api.zh.md              # API Reference

When Are Docs Generated?

Docs are built automatically as the last build target (after package_wheel), provided:

  1. mkdocs is installed: pip install mkdocs-material mkdocs-static-i18n
  2. VULTORCH_BUILD_DOCS=ON (default)

The generated site lands in docs/tutorial/ (served via GitHub Pages).

Build Docs Manually

mkdocs build --clean

Preview Docs Locally

mkdocs serve

Opens at http://127.0.0.1:8000/.

Disable Doc Build

cmake --preset release-windows -DVULTORCH_BUILD_DOCS=OFF

Architecture

Vultorch/
โ”œโ”€โ”€ CMakeLists.txt          # Build system (compile + wheel + docs)
โ”œโ”€โ”€ CMakePresets.json        # Cross-platform build presets
โ”œโ”€โ”€ pyproject.toml           # Python package metadata
โ”œโ”€โ”€ src/                     # C++ core
โ”‚   โ”œโ”€โ”€ engine.cpp/h         # Vulkan + SDL3 + ImGui engine
โ”‚   โ”œโ”€โ”€ tensor_texture.*     # CUDA โ†” Vulkan zero-copy interop
โ”‚   โ”œโ”€โ”€ scene_renderer.*     # Offscreen 3D renderer (MSAA, Blinn-Phong)
โ”‚   โ”œโ”€โ”€ bindings.cpp         # pybind11 Python bindings
โ”‚   โ””โ”€โ”€ shaders/             # GLSL shaders โ†’ SPIR-V
โ”œโ”€โ”€ vultorch/                # Python package
โ”‚   โ”œโ”€โ”€ __init__.py          # High-level API (Window, show, SceneView)
โ”‚   โ”œโ”€โ”€ app.py               # Declarative API (View, Panel, Canvas)
โ”‚   โ”œโ”€โ”€ __init__.pyi         # Type stubs
โ”‚   โ”œโ”€โ”€ ui.pyi               # ImGui binding stubs
โ”‚   โ””โ”€โ”€ py.typed             # PEP 561 marker
โ”œโ”€โ”€ external/                # Git submodules
โ”‚   โ”œโ”€โ”€ pybind11/            # C++ โ†” Python binding
โ”‚   โ”œโ”€โ”€ SDL/                 # Window / input (SDL3)
โ”‚   โ””โ”€โ”€ imgui/               # Dear ImGui (docking branch)
โ”œโ”€โ”€ examples/                # Ready-to-run demos
โ”œโ”€โ”€ tests/                   # pytest tests (GPU + non-GPU)
โ”œโ”€โ”€ tools/                   # Build-time utilities
โ”‚   โ”œโ”€โ”€ make_wheel.py        # Wheel packaging
โ”‚   โ””โ”€โ”€ spv_to_header.py     # SPIR-V โ†’ C header
โ”œโ”€โ”€ scripts/                 # Developer scripts
โ”‚   โ”œโ”€โ”€ build_wheels.py      # Multi-Python wheel builder
โ”‚   โ”œโ”€โ”€ upload_wheels.py     # PyPI upload via twine
โ”‚   โ””โ”€โ”€ setup_wsl2.sh        # WSL2 environment setup
โ”œโ”€โ”€ tutorial/                # MkDocs source (Markdown, EN + ZH)
โ””โ”€โ”€ docs/                    # Generated website (GitHub Pages)

License

MIT


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vultorch-0.5.0-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

vultorch-0.5.0-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

vultorch-0.5.0-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

vultorch-0.5.0-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

vultorch-0.5.0-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file vultorch-0.5.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: vultorch-0.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for vultorch-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8348787afaaaa2d21699aaafd41873c8a1a7356339861f803d418e4861b06042
MD5 d7ab3137de7292df0bfb8aae86168c3d
BLAKE2b-256 ba680b1554ae61ddb5f6bfefb5a6f3fd19d5a7e062a8472f2caf9677c7eb1f6c

See more details on using hashes here.

File details

Details for the file vultorch-0.5.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: vultorch-0.5.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for vultorch-0.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c0c8401bb7ca54072452e6d8bf8af1204c35d8e4f4df5118bc9b546803e830f7
MD5 5c678586bc72d34ea0d91584d888cd56
BLAKE2b-256 4ffbd608d13e31bd6dd1213a50cb3b3521995bbce5e5244617b12be6e449acd5

See more details on using hashes here.

File details

Details for the file vultorch-0.5.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: vultorch-0.5.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for vultorch-0.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5fe0b893d243d09c09bbfb14c7391e8e618a16788b3b30ff91e13737c59cf2ee
MD5 37358fc2cf625d35b1b32657332ec68c
BLAKE2b-256 b2b45b19bc65045aa4ba1c375d7408eb66d21a8cfce835444b7297fbbf9aa12f

See more details on using hashes here.

File details

Details for the file vultorch-0.5.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: vultorch-0.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for vultorch-0.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c539c1f15151c7c193cbaf2729da6e4447645386fe21559ea2a341280729dcc2
MD5 b38f081599f72eb68cb8bf82ffbe8190
BLAKE2b-256 c9b6adf7084c54712c558b21a4e5f97a48df69b93374055633a52645fc31f9b1

See more details on using hashes here.

File details

Details for the file vultorch-0.5.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: vultorch-0.5.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for vultorch-0.5.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b6ad90a10ded7061a8884c476da4c0dcde6fc2dce826e21295dce12ac92ef312
MD5 edc10fb47bbb311cd9d830143a539e43
BLAKE2b-256 6ad199a1dd423f810505820e6d1344f7ee78e1cfb12fd571551c96ea4f469a58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page