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.1rc2.tar.gz (88.4 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.1rc2-cp312-cp312-win_amd64.whl (117.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pyrxmesh-0.2.1rc2-cp312-cp312-manylinux_2_28_x86_64.whl (110.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyrxmesh-0.2.1rc2-cp311-cp311-win_amd64.whl (117.5 MB view details)

Uploaded CPython 3.11Windows x86-64

pyrxmesh-0.2.1rc2-cp311-cp311-manylinux_2_28_x86_64.whl (110.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyrxmesh-0.2.1rc2-cp310-cp310-win_amd64.whl (117.5 MB view details)

Uploaded CPython 3.10Windows x86-64

pyrxmesh-0.2.1rc2-cp310-cp310-manylinux_2_28_x86_64.whl (110.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

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

File metadata

  • Download URL: pyrxmesh-0.2.1rc2.tar.gz
  • Upload date:
  • Size: 88.4 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.1rc2.tar.gz
Algorithm Hash digest
SHA256 c4667ea5f227c56d8084cd535a2e7ceb6f5a6329275fbb5ff15b0111779a96ee
MD5 6b53a33222a05e5b7926cdb7ebbd2bf3
BLAKE2b-256 a43f6efc9347f7489a83be66b9f4750689b7d386fe26661501422ddcb3954179

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2.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.1rc2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 117.5 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.1rc2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81869752332231e82340f3a53c2dd5977588a4fd9d75419efa364d7edec10e96
MD5 195dac04d1601f4cd83944efc380db5f
BLAKE2b-256 734cf78ccef91a2a9ef913d963a37ca2d6cf15ab803bd01f17ebb9321a540da8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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.1rc2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1356a9f7becf4114b65136b4603d1e2a04fb684af200c6b86f5eb94a8ba62011
MD5 9c7d954117ab29bc17dd19511fdcc858
BLAKE2b-256 22b73f1da2e45e0d86763760527a23c44665d1c70caed56c4558df5f9346d131

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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.1rc2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 117.5 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.1rc2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 71cfdfe62ce75aa0ab579ae39c79d720478ae5e1b178d98527ef122f39afa1b8
MD5 4a44009a68dc92e692c92e99a28a48eb
BLAKE2b-256 df8dedac7348b2467ad98139d50d7ed710a9f74111a91c7bdd9ae1e7283bff1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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.1rc2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b6fafd6f03ec7412b0da9c4459e5b65a869de78f07debc9472505de979a5628
MD5 27c93229f54b90ced40901f8dc458cfa
BLAKE2b-256 3a30ef7e75cf4f2b07f7e3a48c722bede55c4f37dc5702bb069baf419801e0be

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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.1rc2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyrxmesh-0.2.1rc2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 117.5 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.1rc2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c921d02ac710f54bdf4fa48e7e28cdff83d4e8d7bc6ff7ae6f4a96354d3794bf
MD5 1c3ee058d311b65b3eea34597a0191de
BLAKE2b-256 a14ff4ac89d4b308977f89f7c69f1224c4d5a6c213f87743e711e6f5367e0fcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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.1rc2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyrxmesh-0.2.1rc2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 799ecd9fb2ca303a59b0a88bff9357b6f2dc61f680dc1c0c7b86e511afd4c149
MD5 53cad8e64df5cf33d6ed0df9ac51309b
BLAKE2b-256 d00d919a56e980f01736b9af6835da37d7e31bc8d8ae01e64204b4f039c87ee5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrxmesh-0.2.1rc2-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