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

Uploaded CPython 3.13Windows x86-64

pynari-1.2.6-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.6-cp313-cp313-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pynari-1.2.6-cp312-cp312-win_amd64.whl (16.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pynari-1.2.6-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.6-cp312-cp312-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pynari-1.2.6-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.6-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.6-cp39-cp39-win_amd64.whl (16.0 MB view details)

Uploaded CPython 3.9Windows x86-64

pynari-1.2.6-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.6-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.6-cp313-cp313-win_amd64.whl.

File metadata

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

File hashes

Hashes for pynari-1.2.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a521b3f426251cd1fb6371cc46061eb2367040646954c80da681128edd82d5dc
MD5 651169d955cf32fe64ff83f73930440a
BLAKE2b-256 ff41f34c6023c3f0ea478e300100ea104231b46f94a1bd4bd429bb7531edde1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 85134857c35feaf36580c49ed608dae24f2f43ba4dcc60d1145d5be23ae9d9a9
MD5 39ecebf3a3578126d0ab65f890f2de13
BLAKE2b-256 961f2291fdf379581502e76e274de54891a09b18145b84ffc39a7cf678a97089

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e8fa9af969961de7eb3e50a90c90b9d8a56c20c99476a6f7508ea91da8b5d3b
MD5 0ac17314e591f7699b350792e8316386
BLAKE2b-256 c478ff68d5fb5d2e768536ae6853bc2eb34e166194cac59fa670ecebfb3b107a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.2.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4bf9299ea0ba1e71a761c01cde35d76ca4c6ed85d6175b7e79279fc892190b99
MD5 7e334c91ecaccf5407fabe567b777a79
BLAKE2b-256 eee1512ddc74da40af8ee339b58ed2c059e0cd5b047282fab96768da46eef541

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 24f207a9cf6b1fcca61a020218d7cfa51f1d175b7474fd3d29264ad7a755ca75
MD5 6d10efe0e9f2abdf7b8a43d6ebc1c2fd
BLAKE2b-256 47237334b715ce05be75af43753f21171c36ce93bcf50272eb856083ea9af10b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bbb8141c830c0ae5cc59293bbb464e01a4b09477bfb826535c2728718d08833
MD5 702549490106068d6f6166c3af089616
BLAKE2b-256 95bed7e5e4a84f5c04ed3589dd167f80116d48959e464e9ddfb15c62e7b839ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 67f944a0215f6379849ca040d918419414516c2f5199c3248e7b29d01619f967
MD5 5cdef9a4f933151d0269e6bb6fac9da6
BLAKE2b-256 ca08f6ab7948269841fd5e332d9243dca1e12ef77b70ab8e4debf99231275167

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5217d3820b367f2078e1c307c3ecb9bfb60e2fd572f490a51f3307046ce800f1
MD5 b364dd6d576f00001382c228b6add02c
BLAKE2b-256 0516344c02dd061f4f134b6b3b49c92d08b81748eca7897fab82145752ea6e31

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pynari-1.2.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 732302d3af61522d5341014e92cd7da61eb162525e6a6750e84c8ad558f5239d
MD5 336265ab4c670632971a558068813e88
BLAKE2b-256 ef0ad8297f5179ab32a5709d9b184e8995387247ce39962d308be373cf157dce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9d32c1827a47e55031d0668df2bc5460bc83c98b0da025317e66239371f4c654
MD5 a80a6ec4c8198591c05ac05362a042de
BLAKE2b-256 ba9535f4500fd0776b7b34a9f0ddd6f88e3bce9108a1799a08af01bd87c256dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pynari-1.2.6-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f930e7f07822b42026485f6b5961fd4e836fffd675bdfdcc4047f117ada71dca
MD5 bf72b8fc654c79235b1968d370dea038
BLAKE2b-256 ce1ffe4d32b2eaf32a568e6be965a3c729bc66bff6140d06594e0112ccb74757

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