NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.39k stars 148 forks source link

Error #2

Closed flynnamy closed 3 years ago

flynnamy commented 3 years ago

ImportError: /tmp/torch_extensions/nvdiffrast_plugin/nvdiffrast_plugin.so: undefined symbol: eglCreateContext How to solve like this?

nurpax commented 3 years ago

Are you using Docker or running natively on a Linux host? Which Linux distro and what version?

The recommended approach is to use docker. The docker image bakes in all the required dependencies, such as OpenGL and EGL. I recommend trying that out first and if you get it working and still think you must replicate the dependencies on your native host, then look at https://github.com/NVlabs/nvdiffrast/blob/main/docker/Dockerfile for a specification on what to install.

yxie20 commented 3 years ago

I am facing the same issue. Using a Docker runs the sample code no problem, but I am hoping to install additional python packages for further development. Docker throws permission errors when I try to install additional packages via pip (e.g. pip install trimesh --user). ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/.local' Check the permissions.

So I opted for compiling nvdiffrast and glew within a fresh conda environment. That leads to the exact problem above. Note that I can import nvdiffrast no problem. The error is thrown at glctx = dr.RasterizeGLContext().

Thank you!

nurpax commented 3 years ago

@yxie20 You can build your own docker image. If you build gltorch:latest with the run_sample.sh script, then you should be able to build your own container with your desired python packages using a Dockerfile like this:

FROM gltorch:latest

RUN pip install <some package>

then build with docker build -t yourcontainer:latest .

Or you can append RUN commands at the end of the Dockerfile that we provide.

We highly recommend Docker on Linux, as different Linux distributions package these dependencies in different ways, leading to problems such as the ones discussed here.

Nvdiffrast compiles our custom OpenGL using Torch extension when you run glctx = dr.RasterizeGLContext() , so it is at this point when you will encounter the EGL linking problem. If you can't use Docker, then I advise to study our Dockerfile and try to replicate EGL and OpenGL installation procedure on your native Linux host.

yxie20 commented 3 years ago

@yxie20 You can build your own docker image. If you build gltorch:latest with the run_sample.sh script, then you should be able to build your own container with your desired python packages using a Dockerfile like this:

FROM gltorch:latest

RUN pip install <some package>

then build with docker build -t yourcontainer:latest .

Or you can append RUN commands at the end of the Dockerfile that we provide.

We highly recommend Docker on Linux, as different Linux distributions package these dependencies in different ways, leading to problems such as the ones discussed here.

Nvdiffrast compiles our custom OpenGL using Torch extension when you run glctx = dr.RasterizeGLContext() , so it is at this point when you will encounter the EGL linking problem. If you can't use Docker, then I advise to study our Dockerfile and try to replicate EGL and OpenGL installation procedure on your native Linux host.

Agreed! I just came to the same conclusion as yours above. Thank you.