Skip to content

Add Cuda support#108

Open
tychedelia wants to merge 2 commits intoprocessing:mainfrom
tychedelia:cuda
Open

Add Cuda support#108
tychedelia wants to merge 2 commits intoprocessing:mainfrom
tychedelia:cuda

Conversation

@tychedelia
Copy link
Copy Markdown
Member

@tychedelia tychedelia commented Apr 7, 2026

Adds support for Cuda.

For the most part, this means doing some copies into external memory that can be used by Cuda and vice-versa.

We expect the user to have installed Cuda (min version 11040) and are using dynamic linking.

Our Python iterop is via __cuda__array__inter.

Some substantive changes to the rest of the code base are the elimination of ImageTextures and GraphicsTargets. These were attempts to pipe gpu resources from the render world to the main world to make accessing gpu resources in the main world easier. We take a new approach here and instead just eagerly look up those resources in the render World and pass them as arguments to stuff as needed.

To test

You can run just py-run cuda.py --features="cuda" in order to test the cuda example, or open the repl with mewnala installed and call .cuda() on an image created with create_image.

@hx2A
Copy link
Copy Markdown

hx2A commented Apr 8, 2026

I am able test this! I can run examples/cuda.py and see a white circle with feathered edges moving in a circular direction with a black background. Here is the output:

$ python ./examples/cuda.py
2026-04-08T04:17:38.103700Z  WARN bevy_asset::io::source: Skip creating file watcher because path "/home/jim/INSTALL/anaconda3/bin/assets" does not exist.
2026-04-08T04:17:38.103715Z  WARN bevy_asset::io::source: AssetSourceId::Default does not have an AssetWatcher configured. Consider adding an "assets" directory.
2026-04-08T04:17:38.205259Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 4090", vendor: 4318, device: 9860, device_type: DiscreteGpu, device_pci_bus_id: "0000:01:00.0", driver: "NVIDIA", driver_info: "590.48.01", backend: Vulkan, subgroup_min_size: 32, subgroup_max_size: 32, transient_saves_memory: false }
2026-04-08T04:17:38.367188Z ERROR bevy_asset: AssetSourceId::Name(assets_directory) must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)
2026-04-08T04:17:38.367206Z ERROR bevy_asset: AssetSourceId::Name(sketch_directory) must be registered before `AssetPlugin` (typically added as part of `DefaultPlugins`)
2026-04-08T04:17:38.375032Z  INFO bevy_pbr::cluster: GPU clustering is supported on this device.
2026-04-08T04:17:38.375067Z  INFO bevy_render::batching::gpu_preprocessing: GPU preprocessing is fully supported on this device.
2026-04-08T04:17:38.375867Z ERROR bevy_asset::server: Asset Source 'AssetSourceId::Name(sketch_directory)' does not exist
Segmentation fault (core dumped)

The Segmentation fault appears a few seconds after I exited the Sketch by closing the window.

Getting the build to run took some time. This computer is a relatively fresh install of ElementaryOS and was missing a lot of headers needed for the compilation. ElementaryOS doesn't seem to have current versions of some necessary libraries. The package manager gives me version 1.21 of just which is super old apparently and I had to manually compile glfw3 to get 3.4 and not 3.3.10. There was also an additional mess I had to clean up because of Anaconda, which I why I ran the python ./examples/cuda.py command after maturin develop --release --features=cuda completed the build. But, I got it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants