# Does LingBot-Map Use CUDA Extensions for Rendering Performance?

> Does LingBot-Map use CUDA extensions for rendering? Discover how this project leverages WebGL and Viser for visualization and CUDA for deep learning and point-cloud processing.

- Repository: [Robbyant/lingbot-map](https://github.com/Robbyant/lingbot-map)
- Tags: deep-dive
- Published: 2026-07-06

---

**LingBot-Map does not use CUDA extensions for rendering; instead, it relies on WebGL via the Viser framework for visualization, while reserving CUDA exclusively for deep-learning inference and point-cloud preprocessing.**

The Robbyant/lingbot-map repository implements a 3D mapping pipeline that strictly separates computation from visualization. While the codebase heavily utilizes NVIDIA CUDA for accelerating neural network operations and geometric filtering, the interactive rendering layer operates through browser-based graphics APIs that are hardware-agnostic and independent of the CUDA toolkit.

## Rendering Architecture: WebGL via Viser

### The PointCloudViewer Implementation

In [`lingbot_map/vis/point_cloud_viewer.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/vis/point_cloud_viewer.py), the `PointCloudViewer` class initializes a `ViserServer` that streams point cloud data to a web interface. This implementation uses **WebGL/HTML Canvas** for GPU-accelerated drawing, not CUDA. The scene graph, camera frustums, and point cloud primitives are rendered by the browser's graphics stack.

```python
self.server = viser.ViserServer(host="0.0.0.0", port=port)

# Add point cloud to the WebGL scene

handle = self.server.scene.add_point_cloud(
    name=f"/frames/{step}/pred_pts",
    points=pred_pts,
    colors=pc_color,
    point_size=self.psize_slider.value,
)

```

*Source:* [`lingbot_map/vis/point_cloud_viewer.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/vis/point_cloud_viewer.py) (lines 99‑104)

No CUDA-specific calls appear in the viewer code. This design choice ensures that visualization works on any device with a modern web browser, regardless of whether an NVIDIA GPU is present.

## Where LingBot-Map Actually Uses CUDA

While rendering avoids CUDA, the repository employs it extensively for compute-intensive tasks. According to the source code, CUDA appears in two primary non-rendering domains:

### PyTorch CUDA for Model Inference

The neural network models in [`lingbot_map/models/gct_base.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/models/gct_base.py) and streaming variants like [`gct_stream.py`](https://github.com/Robbyant/lingbot-map/blob/main/gct_stream.py) utilize PyTorch's CUDA backend for tensor operations. The code explicitly checks for CUDA availability and moves tensors to the GPU device.

```python
if torch.cuda.is_available():
    # Allocate tensors on the GPU

    R_t = torch.from_numpy(T_cw[:3, :3].astype(np.float32)).cuda()
    t_t = torch.from_numpy(T_cw[:3, 3].astype(np.float32)).cuda()

```

*Source:* [`preprocess/oxford.py`](https://github.com/Robbyant/lingbot-map/blob/main/preprocess/oxford.py) (lines 314‑315)

Additionally, mixed-precision training and inference use PyTorch's autocast feature targeting the CUDA device:

```python
with torch.amp.autocast('cuda', enabled=False):
    # … computation …

```

*Source:* [`lingbot_map/models/gct_base.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/models/gct_base.py)

The benchmark script [`scripts/benchmark_gct_memory.py`](https://github.com/Robbyant/lingbot-map/blob/main/scripts/benchmark_gct_memory.py) further demonstrates CUDA device management with explicit `torch.cuda.empty_cache()` calls and memory profiling on the GPU.

### Custom CUDA Kernels for Preprocessing

For geometric operations that exceed PyTorch's built-in capabilities, the repository includes **raw CUDA source files** compiled into custom kernels. These accelerate point-cloud preprocessing before visualization occurs.

**Visibility filtering** is implemented in `preprocess/points_visibility/visibility_kernel.cu`:

```cuda
// visibility_kernel.cu
extern "C" __global__
void visibility_filter(const float* depth, const float* intrinsics, ... ) {
    // GPU‑side implementation
}

```

**Frustum culling** operates similarly in `preprocess/points_visibility/frustum_cull.cu`. These kernels are compiled and launched from Python to filter point clouds on the GPU before the data ever reaches the Viser viewer.

## Compute vs. Rendering: Architecture Comparison

| Pipeline Stage | Technology | Hardware Acceleration | Key Files |
|---------------|------------|---------------------|-----------|
| **Model Inference** | PyTorch | CUDA tensors & autocast | [`lingbot_map/models/gct_base.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/models/gct_base.py), [`scripts/benchmark_gct_memory.py`](https://github.com/Robbyant/lingbot-map/blob/main/scripts/benchmark_gct_memory.py) |
| **Preprocessing** | Custom CUDA kernels | CUDA cores (NVIDIA GPU required) | `preprocess/points_visibility/visibility_kernel.cu`, `frustum_cull.cu` |
| **Visualization** | Viser/WebGL | Browser GPU (any vendor) | [`lingbot_map/vis/point_cloud_viewer.py`](https://github.com/Robbyant/lingbot-map/blob/main/lingbot_map/vis/point_cloud_viewer.py) |

This architecture allows LingBot-Map to perform heavy numeric work on NVIDIA hardware while maintaining portable, cross-platform visualization through standard web technologies.

## Summary

- **CUDA is not used for rendering** in LingBot-Map; the `PointCloudViewer` relies on WebGL via Viser.
- **Model inference** accelerates via PyTorch CUDA tensors and mixed-precision autocasting in [`gct_base.py`](https://github.com/Robbyant/lingbot-map/blob/main/gct_base.py) and related modules.
- **Geometric preprocessing** utilizes custom CUDA kernels (`visibility_kernel.cu`, `frustum_cull.cu`) for visibility filtering and frustum culling.
- The separation of compute (CUDA) and rendering (WebGL) allows the visualization layer to run on hardware without NVIDIA GPUs.

## Frequently Asked Questions

### Does LingBot-Map require an NVIDIA GPU for rendering?

No. The interactive visualization runs in any modern web browser supporting WebGL. You can view point clouds and camera frustums on laptops, tablets, or workstations without NVIDIA hardware, as the rendering is handled by the browser's graphics stack rather than CUDA.

### Can I run LingBot-Map without CUDA installed?

You can run the **visualization** ([`point_cloud_viewer.py`](https://github.com/Robbyant/lingbot-map/blob/main/point_cloud_viewer.py)) without CUDA, but the **inference** and **preprocessing** pipelines will fall back to CPU execution. This significantly impacts performance when processing point clouds through [`gct_base.py`](https://github.com/Robbyant/lingbot-map/blob/main/gct_base.py) or the visibility kernels, as these components explicitly call `torch.cuda.is_available()` and CUDA kernel launches.

### Why does LingBot-Map use custom CUDA kernels instead of PyTorch operations?

For specific geometric operations—particularly visibility filtering and frustum culling in `preprocess/points_visibility/`—custom CUDA kernels provide optimized memory access patterns and parallelization strategies that exceed the performance of generic PyTorch tensor operations. These kernels are compiled separately and invoked from Python for maximum preprocessing throughput.

### What version of CUDA does LingBot-Map require?

The project relies on PyTorch's CUDA abstractions rather than direct CUDA driver calls. Therefore, the required CUDA version aligns with your PyTorch installation's compatibility matrix. The custom kernels in `visibility_kernel.cu` and `frustum_cull.cu` compile against the CUDA toolkit version compatible with the project's PyTorch dependency.