Skip to main content

Python bindings for RXMesh, a CUDA/C++ library for mesh processing on the GPU.

Project description

PyRXMesh

Python bindings for RXMesh, a CUDA/C++ library for GPU mesh processing.

PyRXMesh allows you to keep mesh workflows in Python while using RXMesh data structures and GPU kernels underneath. It supports exchanging arrays and attributes with NumPy and PyTorch, building sparse matrices, and solving linear systems. We use a Python plugin to allow CUDA kernels to be written, compiled, and used directly in Python. Check out CUSTOM_CUDA_PLUGINS.md for more details.

Installation

Install PyRXMesh with:

python -m pip install PyRXMesh

PyRXMesh is a CUDA package. You need an NVIDIA driver compatible with the CUDA version used by the wheel. For source builds and development setup, see DEVELOPING.md.

Simple Example

import pyrxmesh as rx

#Use GPU 0 
rx.init(0) 

mesh = rx.RXMeshStatic("mesh.obj")
print(mesh.num_vertices, mesh.num_edges, mesh.num_faces)

rx.show()

The repository includes a small viewer example:

python examples/load_and_show.py --input mesh.obj

Mesh Attributes

Attributes are data attached to vertices, edges, or faces

import pyrxmesh as rx

mesh = rx.RXMeshStatic("mesh.obj")

coords = mesh.input_vertex_coordinates()
velocity = mesh.add_vertex_attribute("velocity", dtype="float32",
                                     dim=3, location=rx.Location.ALL)

velocity.reset(0.0, rx.Location.DEVICE)

host_coords = coords.to_numpy_copy(source=rx.Location.HOST)
print(host_coords.shape)

NumPy And Torch Interop

Unsuffixed to_* methods return zero-copy views when possible. Methods ending in _copy make an explicit copy.

import pyrxmesh as rx

mesh = rx.RXMeshStatic("mesh.obj")
attr = mesh.add_vertex_attribute("temperature", dtype="float32",
                                 dim=1, location=rx.Location.ALL)

attr.reset(1.0, rx.Location.ALL)

view = attr.to_numpy(rx.Location.HOST)
view[0, 0] = 42.0

owned = attr.to_numpy_copy(source=rx.Location.HOST)
print(owned[0, 0])

Torch views use DLPack:

tensor = attr.to_torch(rx.Location.DEVICE)
tensor += 2.0

Dense And Sparse Matrices

PyRXMesh exposes RXMesh dense matrices and CSR sparse matrices.

import numpy as np
import pyrxmesh as rx

matrix = rx.DenseMatrix(4, 3, dtype="float32", location=rx.Location.ALL)
values = np.arange(12, dtype=np.float32).reshape(4, 3)

matrix.from_numpy_copy(values, target=rx.Location.ALL)
print(matrix.norm2())

Sparse matrices are CSR-only:

mesh = rx.RXMeshStatic("mesh.obj")
laplace_like = mesh.sparse_matrix(rx.Op.VV, dtype="float32")

row_ptr, col_idx, values = laplace_like.to_numpy_copy()
print(laplace_like.shape, laplace_like.nnz)

You can multiply sparse matrices by dense vectors:

x = np.ones((laplace_like.cols, 1), dtype=np.float32)
y = laplace_like.multiply_vector(x)
print(y.to_numpy_copy(source=rx.Location.HOST))

Solvers

RXMesh solver bindings work with SparseMatrix and DenseMatrix objects:

import numpy as np
import pyrxmesh as rx

row_ptr = np.array([0, 2, 5, 7], dtype=np.int32)
col_idx = np.array([0, 1, 0, 1, 2, 1, 2], dtype=np.int32)
values = np.array([4, 1, 1, 3, 1, 1, 2], dtype=np.float32)

A = rx.SparseMatrix.from_numpy_copy(row_ptr, col_idx, values,
                                    shape=(3, 3), dtype="float32")

b = rx.DenseMatrix(3, 1, dtype="float32", location=rx.Location.ALL)
b.from_numpy_copy(np.array([[1], [2], [3]], dtype=np.float32))

solver = rx.CGSolver(A, unknown_dim=1)
x = solver.solve(b)

print(x.to_numpy_copy(source=rx.Location.HOST))

Documentation

  • RXMeshDocs: RXMesh CUDA/C++ documentation website
  • DEVELOPING.md: build PyRXMesh from source and work against RXMesh forks, tags, or local checkouts.
  • CUSTOM_CUDA_PLUGINS.md: write small compiled CUDA plugins that operate on PyRXMesh meshes and attributes.

Project details


Download files

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

Source Distribution

pyrxmesh-0.2.1rc1.tar.gz (84.9 kB view details)

Uploaded Source

Built Distributions

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

pyrxmesh-0.2.1rc1-cp312-cp312-win_amd64.whl (54.3 MB view details)

Uploaded CPython 3.12Windows x86-64

pyrxmesh-0.2.1rc1-cp312-cp312-manylinux_2_28_x86_64.whl (54.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyrxmesh-0.2.1rc1-cp311-cp311-win_amd64.whl (54.3 MB view details)

Uploaded CPython 3.11Windows x86-64

pyrxmesh-0.2.1rc1-cp311-cp311-manylinux_2_28_x86_64.whl (54.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyrxmesh-0.2.1rc1-cp310-cp310-win_amd64.whl (54.3 MB view details)

Uploaded CPython 3.10Windows x86-64

pyrxmesh-0.2.1rc1-cp310-cp310-manylinux_2_28_x86_64.whl (54.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file pyrxmesh-0.2.1rc1.tar.gz.

File metadata

  • Download URL: pyrxmesh-0.2.1rc1.tar.gz
  • Upload date:
  • Size: 84.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrxmesh-0.2.1rc1.tar.gz
Algorithm Hash digest
SHA256 4f9382bd8ab8f0e246e06e039ee6a55bb59cab8c23b371c5564dfae8d28a087f
MD5 5310de7e3b6f034118613b9bed1cfdf0
BLAKE2b-256 e4383ac8abf05dcc71eccb5bb6f8fd6345bdcbf975e954f08f16de3dd83575b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1.tar.gz:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 54.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 86db7f5c7346cfd949d68d08ba93dee82519c469e5430a30347e63dbdd0247ec
MD5 9e978876a65fd37d263244a6cb431d2d
BLAKE2b-256 21ff96e3aaa2548ee1cdb741a30bd4c6fde2ac1b69edf439b688a3f9e5626a5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d997048623b56bdccd734939a00812a4373eac95f787e5ae32696af7da7bc91b
MD5 699588d3a456eb79443dbc18c449de71
BLAKE2b-256 d8f3b159dd14818129ecdb9aabe3b59ea380d12b91c0e926f8127bd788b65a2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 54.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e289135794c0e034f71404a596b18da823f1b0b2ec7acee8cde5155fc78cdbb
MD5 d0dbfd80ea97c0d60f4e02b09dc03bc4
BLAKE2b-256 62f8253f6629be84eb110056d4128487ab2eb9045b7dbb581ccb2068f61a8657

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4cba7c4b17c27cf9522714f6e937a6cf0dafb81615fbd5f6a0814a1976540e00
MD5 e84a3671a2c9ca105e44bf52cc434d8b
BLAKE2b-256 97fd0d84658e0cc746babfa87bd323bd6da5984a4858095aace58c5e672d1d34

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 54.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2a4daaf963fcb38a1a13041cac8abaaa600d76b91c73f6669a08d587e2f10dad
MD5 bf96c6241a4b3e36b7cfc1131c65e3fe
BLAKE2b-256 b8921a35e99fac8db629e414853106d9121f96afd7069f656c7c28ee0c87dd8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyrxmesh-0.2.1rc1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b8a3ed22aba5d8e22fb8d5a163086e84ad9667be4b07cb3442dcf9f90b711ee
MD5 d306fc192ec1add57dfdee023a859918
BLAKE2b-256 0affa0b36134e963a42b7e1e565309d6226736f851f623f9113cf4f9742e95c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc1-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Ahdhn/PyRXMesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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