Git Product home page Git Product logo

python-optix's Introduction

Python-OptiX

Python wrapper for the OptiX 7 raytracing engine.

Python-OptiX wraps the original OptiX C-like API using Cython while aiming to provide a more pythonic, object-oriented interface using the CuPy package.

Supported Platforms

Only Linux is officially supported at the moment. Experimental windows support is available.

OptiX Versions

Python-OptiX always supports the most recent version of the OptiX SDK. The current version therefore supports OptiX 7.6.0

Installation

Dependencies

Install a recent version of the CUDA Toolkit and the OptiX 7.6.0 SDK

Make sure the CUDA header files are installed as well.

Note, that for some variants of the CUDA Toolkit, like the one installed by the conda package manager, these are not installed by default. conda-environments require the additional cudatoolkit-dev package.

Environment

python-optix requires both the OptiX as well as the CUDA include path during setup as well as runtime to compile the CUDA kernels. Therefore, it is necessary to either add both locations to the system PATH or set the CUDA_PATH and OPTIX_PATH variables to the respective locations.

The setup additionally has the option to embed the OptiX header files into the python-optix installation. If the variable OPTIX_EMBED_HEADERS is set to 1, the setup will copy the headers from the OptiX SDK directory into the generated wheel.

If this option was chosen during setup, setting the OPTIX_PATH is no longer required as the embedded headers will be utilized then.

Using pip

export OPTIX_PATH=/path/to/optix
export CUDA_PATH=/path/to/cuda_toolkit
export OPTIX_EMBED_HEADERS=1 # embed the optix headers into the package
python -m pip install python-optix

From source

git clone https://github.com/mortacious/python-optix.git
cd python-optix
export OPTIX_PATH=/path/to/optix
export CUDA_PATH=/path/to/cuda_toolkit
export OPTIX_EMBED_HEADERS=1 # embed the optix headers into the package
python -m pip install [-e] .

python-optix's People

Contributors

keckj avatar mortacious avatar syoyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

keckj syoyo

python-optix's Issues

Dynamic Geometry Example requires source file vector_functions.h

Trying the new dynamic materials and geometry examples, and the materials one works well. However the dynamic geometry example fails with error message

CompileException: /home/timtitan/Documents/10-19-Research-Projects/14-Electromagnetics-Modelling/14.04 Python Development/python-optix/examples/cuda/vec_math.h(43): catastrophic error: cannot open source file "vector_functions.h"

Looking at the code in vec_math.h it calls for vector types and vector functions. Neither is present in the examples/cuda folder along with vec_math.h

Doesn't run examples

First of all, I downgraded from 7.7.0 to 7.6.0 SDK in order to compile the package.

Running a denoising example on a sample image yields:

python denolser.py input.exr (The name is mis-spelled).

RuntimeError: OPTIX_ERROR_INVALID_VALUE: Invalid value
Exception ignored in: 'optix.denoiser.Denoiser.__dealloc__'
Traceback (most recent call last):
  File "/home/gr/python-optix/examples/denolser.py", line 56, in <module>
    denoiser = ox.Denoiser(ctx, model_kind=model_kind, guide_albedo=args.albedo is not None, guide_normals=args.normal is not None, kp_mode=args.k)
RuntimeError: OPTIX_ERROR_INVALID_VALUE: Invalid value
Traceback (most recent call last):
  File "/home/gr/python-optix/examples/denolser.py", line 56, in <module>
    denoiser = ox.Denoiser(ctx, model_kind=model_kind, guide_albedo=args.albedo is not None, guide_normals=args.normal is not None, kp_mode=args.k)
  File "optix/denoiser.pyx", line 154, in optix.denoiser.Denoiser.__init__
AttributeError: 'optix.denoiser.Denoiser' object has no attribute '_guide_layer_scratch_size'

I'm not sure why this error is thrown as _guide_layer_scratch_size attribute is being initialized in the constructor.

Removing _guide_layer_scratch_size from the init passes the issue downstream:

Traceback (most recent call last):
  File "/home/gr/python-optix/examples/denolser.py", line 58, in <module>
    ret = denoiser.invoke(color_image, albedo=albedo_image if args.albedo else None, normals=normal_image if args.normal else None)
  File "optix/denoiser.pyx", line 294, in optix.denoiser.Denoiser.invoke
  File "optix/denoiser.pyx", line 199, in optix.denoiser.Denoiser._init_denoiser
AttributeError: 'optix.denoiser.Denoiser' object has no attribute '_intensity_scratch_size'

Setup: Ubuntu 22.04 VM with CUDA 12.1 & 530.30.02 Driver & 7.6.0 OptiX.

Sphere primitive

Hello,
Thank you for your quality work
I'd like to ask you a question about Optix 7 Spheres primitives. Are they available in your Python interface as in latest Optix?I was wondering because I saw that in the spheres.py example you use Custom Primitive.
Thanks a lot,

Compiling from source with setup.py does not copy headers

Compiling from source does not copy headers:

  • python3 setup.py install does not copy include files (optix.h)
  • pip3 install . works because custom_bdist_wheel is executed in setup.py

When using setup.py, get_local_optix_include_path() returns None which results in module creation failure:

module = optix.Module(context=ctx, src=cuda_source, module_compile_options=compile_opts, pipeline_compile_options=pipeline_opts)
  File "optix/module.pyx", line 257, in optix.module.Module.__init__
  File "optix/module.pyx", line 413, in optix.module.Module.compile_cuda_ptx
  File "/usr/lib/python3.9/genericpath.py", line 19, in exists
    os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

There is warning for missing local headers that could have helped to pinpoint the problem but it is not shown because the condition triggering the warning crashes on None path (optix/module.pyx:413).

In the "From source" in the section in the README.md it is documented to use setup.py.

Installing python-optix

Hello, I am trying to install your package to try out the library, and it is not discovering the optix installation. Which specific folder is it looking for in the Path? I have tried include and the overall folder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.