mitsuba-renderer / mitsuba2

Mitsuba 2: A Retargetable Forward and Inverse Renderer
Other
2.04k stars 267 forks source link

[🐛 bug report] code 139 (interrupted by signal 11: SIGSEGV) when converting parameter to torch tensor #278

Open AndresCasado opened 3 years ago

AndresCasado commented 3 years ago

Summary

After some struggle compiling Mitsuba2 with CUDA support, I finally managed to get it working, but trying to run the PyTorch integration example results in an error.

System configuration

Description

After reading some solved issues about OptiX, PTX and CUDA I finally managed to compile Mitsuba2 with GPU support by editing the compute capability in ptx Makefile and the Enoki CMAKE settings.

Then, as I usually work with virtualenvs and PyCharm, I created a new virtualenv, installed PyTorch in it and manually edited its PYTHONPATH to add the compiled version of Mitsuba bindings.

Scripts to import Mitsuba and detect the variants work fine. Scripts to create a tensor on GPU memory using PyTorch work.

But running the differentiable rendering example suddenly exits the scripts after this command:

param_ref = params['red.reflectance.value'].torch()

The error is:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

Setting the virtualenv as the Python executable in CMAKE does not help.

The command params[...].numpy() works fine.

Steps to reproduce

  1. Create virtualenv (in PyCharm)
  2. Install PyTorch in virtualenv
  3. Set virtualenv as Python executable in CMAKE
  4. Compile Mitsuba with gpu_autodiff_* support
  5. Add Mitsuba Python packages directory to virtualenv PYTHONPATH in PyCharm
  6. Run differentiable rendering with PyTorch example
Speierers commented 3 years ago

Hi @AndresCasado ,

We are currently working on a major refactoring of the Mitsuba + Enoki codebase. This will likely be fixed in the new version. Unfortunately I won't have the time to look into your issue on the current master branch.

You could maybe try to debug this with a simpler piece of code? E.g.

import mitsuba
mitsuba.set_variant('gpu_autodiff_rgb')
from mitsuba.core import Float

a = Float(4.4)
b = a.torch()

print(b)
AndresCasado commented 3 years ago

Thanks for your response.

If there is an ongoing refactoring I understand this is not high priority. I'll wait for the new version and test again.

In any case, this is the output after running your suggestion:

2020-09-22 09:32:21 INFO  main  [optix_api.cpp:56] Dynamic loading of the Optix library ..

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)