mortacious / python-optix

Python wrapper for the OptiX 7 raytracing engine using Cython.
MIT License
23 stars 3 forks source link

Installing python-optix #3

Closed LyceanEM closed 2 years ago

LyceanEM commented 3 years ago

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.

mortacious commented 3 years ago

The package will attempt to locate the OptiX headers by checking all directories in the PATH environment variable for a path named optix/include, e.g. in /opt/optix/include

Optionally, the environment variable OPTIX_PATH can be set to the directory of the OptiX SDK (e.g. /home/user/optix) to support non-standard locations.

Note that the headers are also needed at runtime to compile the CUDA device code.

LyceanEM commented 3 years ago

Thank you, using OPTIX_PATH, and by installing cudatoolkit and cupy first I was able to install python-optix. However when I tried the examples they all failed, causing the kernel to restart without an error message. Playing around a little, it seems that any call on ox.DeviceContext causes the kernel to restart. Calling cp.cuda.device.Device() does not cause this issue, and I have been using cuda via Numba and cuSignal without any issues thus far.

mortacious commented 3 years ago

This is kinda hard to debug without an error message. It might be a problem with your OptiX installation though. Could you try running one of the default examples by Nvidia from the SDK?

mortacious commented 2 years ago

Since there seems to be no further activity here, I am closing the issue. Should it become necessary, you are welcome to reopen it.

LyceanEM commented 2 years ago

Hello, sorry for going silent. Quite alot of other work preventing me from coming back and try installing Optix. I have confirmed that some of the examples work, but when I try the hello.py example I get the following error message.

DEBUG:root:All knobs on default.

DEBUG:root:Opened database: "/var/tmp/OptixCache_timtitan/optix7cache.db" DEBUG:root: Cache data size: "72.7 KiB" Traceback (most recent call last):

File "/home/timtitan/anaconda3/envs/PythonOptix/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 653, in compile nvrtc.compileProgram(self.ptr, options)

File "cupy_backends/cuda/libs/nvrtc.pyx", line 133, in cupy_backends.cuda.libs.nvrtc.compileProgram

File "cupy_backends/cuda/libs/nvrtc.pyx", line 145, in cupy_backends.cuda.libs.nvrtc.compileProgram

File "cupy_backends/cuda/libs/nvrtc.pyx", line 64, in cupy_backends.cuda.libs.nvrtc.check_status

NVRTCError: NVRTC_ERROR_COMPILATION (6)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/timtitan/Documents/10-19-Research-Projects/14-Electromagnetics-Modelling/14.04 Python Development/python-optix/examples/hello.py", line 81, in module = create_module(ctx, pipeline_options)

File "/home/timtitan/Documents/10-19-Research-Projects/14-Electromagnetics-Modelling/14.04 Python Development/python-optix/examples/hello.py", line 12, in create_module module = ox.Module(ctx, 'cuda/hello.cu', compile_opts, pipeline_opts)

File "optix/module.pyx", line 106, in optix.module.Module.init

File "optix/module.pyx", line 138, in optix.module.Module._compile_cuda_ptx

File "/home/timtitan/anaconda3/envs/PythonOptix/lib/python3.8/site-packages/cupy/cuda/compiler.py", line 670, in compile raise CompileException(log, self.src, self.name, options,

CompileException: cuda/hello.cu(29): catastrophic error: cannot open source file "optix.h"

1 catastrophic error detected in the compilation of "cuda/hello.cu". Compilation terminated.

On checking through the Optix examples I find optixVolumeViewer and optixMotionGeometry fail NVRTC Compilation as well, which I assume is due to NVTX not being detected by ccmake for Optix install, but I have nvtx3 in my path. Any advice here would be greatly appreciated.

mortacious commented 2 years ago

Compiling with NVRTC generally seems to work for you. However, the OptiX headers are still not found.

Python-optix requires the path to the headers both when installing the package (for the host API) and when compiling new CUDA-code (for the client API) if the source code is not in PTX-format. In both cases that same code is used for finding the path, so setting the OPTIX_PATH environment variable again for the script execution should help you here.

LyceanEM commented 2 years ago

Sorry I mean none of the python-optix examples work, and some of the optix examples work.

mortacious commented 2 years ago

You can verify, that the OptiX-path is found correctly be running

from optix.path_utility import get_optix_include_path
print(get_optix_include_path())

If this function does not return the include directory of you OptiX-Installation or None you'll have to set the OPTIX_PATH

LyceanEM commented 2 years ago

Well that returns None, but checking for path I get this

(PythonOptix) timtitan@Vulkan:\~$ echo $PATH /usr/local/bin:/usr/local/cuda-11.5/include:/usr/local/cuda-11.5/bin:/home/timtitan/Optix/NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/include:/home/timtitan/anaconda3/envs/PythonOptix/bin:/home/timtitan/anaconda3/condabin:/home/timtitan/.local/bin:/home/timtitan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin (PythonOptix) timtitan@Vulkan:\~$ echo $OPTIX_PATH /home/timtitan/Optix/NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK-Build:/home/timtitan/Optix/NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/include:/home/timtitan/anaconda3/bin:/home/timtitan/anaconda3/condabin:/home/timtitan/.local/bin:/home/timtitan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin (PythonOptix) timtitan@Vulkan:~$

LyceanEM commented 2 years ago

Sorted it now following the clues in the codebase. Thank you