Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[F glutil.cpp:338] eglInitialize() failed Aborted (core dumped) when render with kaolin and nvdiffrast #796

Open
walsvid opened this issue May 14, 2024 · 1 comment

Comments

@walsvid
Copy link

walsvid commented May 14, 2024

I have discovered that under certain NVIDIA driver versions and OpenGL versions, using nvdiffrast within kaolin to render causes errors. As mentioned in this issue sicxu/Deep3DFaceRecon_pytorch#2, the problem is related to the use of nvdiff.RasterizeGLContext instead of nvdiff.RasterizeCudaContext. I noticed that in the kaolin code, the Context is initialized and fixed to always be GLContext.

def _get_nvdiff_glctx(device):
if device not in _device2glctx:
_device2glctx[device] = nvdiff.RasterizeGLContext(
output_db=False, device=device)
return _device2glctx[device]

After changing this to nvdiff.RasterizeCudaContext and recompiling kaolin, I used kal.render.mesh.rasterize and selected 'nvdiffrast' as the backend for rendering. The result was normal, with the only issue being that the output must be a multiple of 8.

I would like to know if there are plans in future versions to make the Context type a selectable parameter. Additionally, I would like to inquire if there is a need to contribute a pull request.

@shumash
Copy link
Collaborator

shumash commented Jul 19, 2024

Hello, thanks for your detailed note!

In fact, there is an option to set the default context without recompiling the code with: kal.render.mesh.nvdiffrast_context.nvdiffrast_use_cuda(). However, it looks like there is a bug in that function (thank you for alerting us to it).

You can still bypass that bug and set your preferred context using:

import kaolin as kal
import nvdiffrast.torch

kal.render.mesh.nvdiffrast_context.set_default_nvdiffrast_context(
    nvdiffrast.torch.RasterizeCudaContext("cuda"), "cuda")

print(kal.render.mesh.nvdiffrast_context.default_nvdiffrast_context(device="cuda"))

# Prints: <nvdiffrast.torch.ops.RasterizeCudaContext object at 0x7fc42c2164c0>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants