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.

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.1.2-cp313-cp313-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.13Windows x86-64

pynari-1.1.2-cp313-cp313-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pynari-1.1.2-cp313-cp313-macosx_11_0_arm64.whl (17.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pynari-1.1.2-cp312-cp312-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.1.2-cp312-cp312-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pynari-1.1.2-cp312-cp312-macosx_11_0_arm64.whl (17.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pynari-1.1.2-cp311-cp311-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pynari-1.1.2-cp310-cp310-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pynari-1.1.2-cp39-cp39-win_amd64.whl (16.3 MB view details)

Uploaded CPython 3.9Windows x86-64

pynari-1.1.2-cp39-cp39-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pynari-1.1.2-cp39-cp39-macosx_11_0_arm64.whl (17.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pynari-1.1.2-cp38-cp38-manylinux_2_34_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pynari-1.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 76599cfb108891d604a94025e45aef3ef6a697e6171d7f183b2ab90cac0f3248
MD5 ae9665d150b4bf2dc80107cee6505532
BLAKE2b-256 c91102839b1661946697c97dede121e59b2edca00cb6e2d4de1aab0fb9a33733

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6099a7581923e1cb23bcab8f792571e82d89b8b5afb82cdb77b1ef1afb4696cf
MD5 67635efbf2fe2cbb8467a44dab73b45a
BLAKE2b-256 a666086d09039a846eb51304ec7e3b50fbbff3b52c24acf47f2d4bc35025c394

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0f4818b36945c5eca81778f3c83404a6042052be18c0f520421784fbc0ad8c5
MD5 5c9cc23efcba0eeeff46d549c1bbcb82
BLAKE2b-256 f05150ca2014b08046fedc6368953d252d06bc6feebc99580f4887f136ed896a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 416d72988bf4cb8f63767fad6d540c777ab49ed371b22f8c69b3dda6b02d556d
MD5 00c84a5cf156c4a5a32328b536270aae
BLAKE2b-256 b0971c1f2c83defe09cd4065300dee8a9bdeda45d8d39a6c638757919de3f8f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 718e60bb1df4475c7d02030c1884ee7f7366016b4631726e916c4e6db18c0509
MD5 9015ebbb89e53df3d61819f0cc6fd9af
BLAKE2b-256 e309d40e3b1a8b8778ba4936bd628912856cf4d33e5069ac9d2b05ab83ac1e9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 208104dd341d1defa52bfda0a132e0757dbf1415e3eac3793ea2e4c0e9680adf
MD5 72f0a482236e010294f0316c785a648f
BLAKE2b-256 7f3413652fed08d3471ccc752f720765e042f17e03f84a2b58652818ce94cf24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8d26d4bcd79a6a623e7e8c2c954c99bdc94cfd5622ddd4c3ae4d64d2cf2e296d
MD5 b6b7f1f5bf7b0e3cd8d65b21f0e631de
BLAKE2b-256 19a0fb2329c036bbed07202d9d299928bba1b82ff1307a52dceb1743efb20f27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f761e85dc1130208486a97593ca81d547fa1f093520517e6240b8e71a77c6189
MD5 d7ded927c86d59f01ca5630194a1c775
BLAKE2b-256 23a5e77232c548998e13022e4d66ec28ff2c44bb0e02ffe50983557c669f3daa

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5942b59be67b5db976bd59263d60c23258f4646b29f533cd7476802f99c09b22
MD5 8a60e0bab99877ebbcb7dd06bd252d09
BLAKE2b-256 ff250d5b8400746cae5925aef0f2a99cd90eae21391f40a996fa0bef6f720e13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 583dcfe4927180731e9df47ef1dfcc838b713165bfc636089e19ff3930f4ba81
MD5 9cf301ebf0b0d3746812968b5162b643
BLAKE2b-256 227e598dcf9e980d8e365605fc1fe552387f47bb4b6ee7e4f024c88ab9e5bfcf

See more details on using hashes here.

File details

Details for the file pynari-1.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pynari-1.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06485db2d6343ca2589209435bbdbfacad4c12ccf5a2aace66d4a3580459adca
MD5 991fc8e57b97172a6d4304c72752fbf5
BLAKE2b-256 d5f65af1e73ccb33ad4d3654a55e032a2449b2432ac5f83dc54348c5341a166b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.1.2-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 09065014bba8ba18da05385c1830cb770503d59f39c55ca868bcbd10d6a94a66
MD5 0516560a4615b6a963c6cf42aba128cc
BLAKE2b-256 25054e4252dd8fe0f286d65eee50c1bb4e614e35cc62cc9dd594d2f1511dec18

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