Skip to main content

Python bindings for ANARI

Project description

pynari - Python Bindings for ANARI

This project provides a python interface for the Khronos ANARI rendering API. This implementation currently requires a CUDA capable GPU (support for other backends will be added at a later time).

Usage - Quickstart

Assuming you already know how the ANARI API works (and that you have pip-installed this package) you can use ANARI in python as follows: First, import this package

import pynari as anari

(for all the steps below we assume you imported pynari as anari; this is not required, but please take this in mind for the examples below).

Once the package has been imported you can then create a ANARI "device" using

device = anari.newDevice('default')

(where desired, the string passed to 'newDevice' allows for selecting a specific ANARI device, see below; 'default' in this case will currently select a 'barney' backend, see https://github.com/ingowald/barney).

You can then create various ANARI actor objects through creator-methods on that device, such as, for example

world = device.newWorld()
mesh  = device.newGeometry('triangle')
array = device.newArray(anari.FLOAT32_VEC3,vertex)

etc.

Large arrays (such as vertex or index arrays for a triangle mesh) are expected to be populated using numpy, and wrapped in the ANARI 'array' type:

import numpy as np
...
vertex = np.array(...,dtype=np.float32)
mesh.setParameter('vertex.position',anari.ARRAY,
                  device.newArray(anari.FLOAT32_VEC3,vertex));
index  = np.array(...,dtype=np.uint32)
mesh.setParameter('primitive.index',anari.ARRAY,
                  device.newArray(anari.UINT32_VEC3,index));

The ANARI API, and how it is exposed in pynari

For a full description of what ANARI Objects are, what kind of objects exist, and how they work, please refer to the ANARI API Spec at https://registry.khronos.org/ANARI/specs/1.0/ANARI-1.0.html .

Since the official ANARI API is a plain C API we could not implement this literally, but had to make certain changes to make ti more "pythonic". Basically, these rules were applied (we will assume that the pynari module was imported under the alias as anari):

  • If there is a C constant/enum of name ANARI_XYZ, it is exposed as anari.XYZ. Example: the C enum of ANARI_FLOAT32 is anari.FLOAT32 in pynari.

  • If there is a C API function of anariFunctionXyz(ANARIDevice device, ...) it will be exposed as device.functionXyz(...). Note that in order to remain as close to the C-style API as possible we use CAML-case for function names, not python-casing. I.e., pynari uses device.functionXyz(...), not device.function_xyz(...).

Examples

For a list of several samples, please visit the pynari github repo https://github.com/ingowald/pynari

Supported and Built-in Devices

In ANARI, the 'device' abstraction aims at allowing for what is essentially the concept of a "driver"--i.e., a specific implementation of the hardware for a specific set of underlying hardware, or features. On the OS level, this is realized through installing of different ANARI implementations (e.g., barney or visrtx for CUDA GPUs, or ospray for Intel CPUs and GPUs), and then at runtime selecting one of then by passing a proper 'device name' identifier.

In pynari, we currently expose the device concept as follows:

  • If installed through pip, pynari comes with two "baked" devices that are pre-supplied with the pynari pip package, even if no ANARI devices are installed on the OS level: barney_cuda, and barney_cpu (see below).

  • the barney_cuda device (shipped with pynari's pip install) is a CUDA- and OptiX accelerated path tracer (see https://github.com/ingowald/barney). barney_cuda requires a OptiX-capable NVIDIA GPU with driver 535 or newer. Specifying device as 'barney_cuda' (or 'gpu' for short) will try to load this device, and throw an exception if this is not possible (eg, if no GPU can be found).

  • the barney_cpu device (also shipped with pynari's pip install) is a (much!) slower CPU-only fallback (based on embree) that should produce similar images. barney_cpu does not require an NVIDIA GPU, but will be significantly slower. Specifying barney_cpu (or cpu, for short) will try to load this device, and throw an exception if this did not succeed.

  • Specifying device as 'default' first try to load barney_cuda, and use that if possible; if not it will try to load barney_cpu.

  • For any device name other than default, barney_cuda, 'gpu', barney_cpu, or 'cpu', pynari will look for a system-installed ANARI implementation, and ask this to create a device of that name.

Issues

For any issues, bugs, or feature requests, please use the github pynari issue tracker.

Version History

v1.1.3

  • support for macOS

  • support for CPU-fallback when no GPU is present (in part on mac)

  • anari.newDevice(<devName>) will accept device names 'cuda' and 'cpu'. 'default' will try to load 'cuda', and if that fails, fall back to 'cpu'.

  • supports pass-through to system-installed anari device. Device names other than 'cuda', 'cpu', or 'default' will read the env-var ANARI_LIBRARY, and use system-installed anari library specified therein.

v1.1.4

  • updated to latest barney, with various fixes to lighting code and fixed structured volume data.

  • baked backends built for 'all-major' CUDA architectures.

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.

pynari-1.2.0-cp313-cp313-win_amd64.whl (15.4 MB view details)

Uploaded CPython 3.13Windows x86-64

pynari-1.2.0-cp313-cp313-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pynari-1.2.0-cp313-cp313-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pynari-1.2.0-cp312-cp312-win_amd64.whl (15.4 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.2.0-cp312-cp312-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pynari-1.2.0-cp312-cp312-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pynari-1.2.0-cp311-cp311-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pynari-1.2.0-cp310-cp310-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pynari-1.2.0-cp39-cp39-win_amd64.whl (15.4 MB view details)

Uploaded CPython 3.9Windows x86-64

pynari-1.2.0-cp39-cp39-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pynari-1.2.0-cp38-cp38-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file pynari-1.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pynari-1.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 15.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pynari-1.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2f297fa39e4487375cf1b50bfa0b8efa25190722edf32a4d6e9279e94bf576c4
MD5 4d858753d87ac9667a8fde71c8176950
BLAKE2b-256 613462adecbf5f6bb737a52df730bf3efd1cf3835571d9b0fb749a498fb21f95

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d7aa8f228ff242fb9da7dbf5688af7fc3572d72ef665b302b1c20df95571e5b6
MD5 708c98a82509fbf0f9c5cb927b8a6d0b
BLAKE2b-256 14938bd20888c142ba335c5629a4cc735b30e9192a0c063109b900c9bc082b7a

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9fa302469c2f06f1810518659bb6a215bbe6fe7b1d5d5f50055d2a7b0166a75
MD5 16a742ea6c5df1e9850a21ef97bff8cd
BLAKE2b-256 497c2c134aa0bc85ab9f8845df1328f4fc0327308556ec48879def7b2e7223f9

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pynari-1.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 15.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pynari-1.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 025e844cd42aff73ab4bc0dcd285849bdf4e47c5992d6593c3268cbeaaac92b1
MD5 09b9b3ad0b355eda39c43762ba1a2c54
BLAKE2b-256 2ecf8b9e83dccff019e80bde10058d9300ff1f8ffc283c30381ba59c7c4f73a9

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 855fe15127aa37bd94586feac3044009730618765d88f79145b065349c1dde97
MD5 bbb469cb611711cad0c75760b66d0463
BLAKE2b-256 5a2190eb64c483758652ba82b9b677119204dcd180d16bd8455434ea551b1730

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12c3738db961bbf21c681377fd5c014b15130c738d7316c3b6b60a008581268b
MD5 056305a30f3153dff0c24ade2871d913
BLAKE2b-256 7dbde352e0f55e0de540a4b7c782a62b0351b7be9064bb3aeafc4f7bdb59cf84

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 915cbea9669f4bc3b8e21bd4b8c17e7736ff23b1f995a2f5ff5d6a503e9570a6
MD5 e76dbcf757a652d2d22521bdcdae6e04
BLAKE2b-256 8d04ba52dfb79d112ea076e07214d26515c24fff642cb03a9f587ed0b7b84acd

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dfc7873d96e56aba07e3a3e19957101d59d821671ef49a145927db81da04f882
MD5 ce83cc92762fc821a2ef26ed5de7522b
BLAKE2b-256 759a22a6cceb868c283c16a1a0eff2e75d9b6961ba11374ef51b683124798f9e

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pynari-1.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 15.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pynari-1.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e3e3c510942ee2ddc763bebbb6daec9a756bea45b1f537c96b35090ea4b42b66
MD5 84bbeef4355d3dfbbd0a40e23a879eb4
BLAKE2b-256 8f50a934feb2c7c839325d796632fa1e8bdda55e99ad46d568e7729b7811f81f

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0e56b35fad01bbb46c26080686d934a73ba762c724c6988e3f5ad05e05281df0
MD5 f4cdef0fda3b461b1a5963f8f7702f1a
BLAKE2b-256 d251c9dde95e104c4c18eeba59e74eb72804563759d0205a23e7e1c847f5309a

See more details on using hashes here.

File details

Details for the file pynari-1.2.0-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pynari-1.2.0-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e40a62977040bd1165c1ad0ebfcbae66470ec740daa3a1ba3764f6e2c9d91e36
MD5 b8eacf97e43eb46e8636ee3e8e985ba4
BLAKE2b-256 86b00dc6a21fc4a333bd42e2cb48214c0a3d34c06682d42b184d5d9c8f01c9bc

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