NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.31k stars 139 forks source link

RuntimeError: OpenGL 4.4 or later is required / WSL2 Ubuntu problem? #90

Closed adevra closed 1 year ago

adevra commented 1 year ago

Hi, I've been trying to build Deep3DFaceRecon in WSL2 Ubuntu 20.04 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 515.65.01 Driver Version: 516.94 CUDA Version: 11.7 | |-------------------------------+----------------------+----------------------+

I get this error and nothing come out of my troubleshooting efforts, I wonder if there is an issue with WSL2 Ubuntu and nvdiffrast


Transfer BFM09 to BFM_model_front......
model [FaceReconModel] was created
loading the model from ./checkpoints/ade/epoch_20.pth
0 ./datasets/examples/000002.jpg
Traceback (most recent call last):
  File "test.py", line 72, in <module>
    main(0, opt,opt.img_folder)
  File "test.py", line 62, in main
    model.test()           # run inference
  File "/home/adunix/Deep3DFaceRecon_pytorch/models/base_model.py", line 162, in test
    self.forward()
  File "/home/adunix/Deep3DFaceRecon_pytorch/models/facerecon_model.py", line 139, in forward
    self.pred_vertex, self.facemodel.face_buf, feat=self.pred_color)
  File "/home/adunix/anaconda3/envs/deep3d_pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/adunix/Deep3DFaceRecon_pytorch/util/nvdiffrast.py", line 58, in forward
    self.glctx = dr.RasterizeGLContext(device=device)
  File "/home/adunix/anaconda3/envs/deep3d_pytorch/lib/python3.6/site-packages/nvdiffrast/torch/ops.py", line 221, in __init__
    self.cpp_wrapper = _get_plugin(gl=True).RasterizeGLStateWrapper(output_db, mode == 'automatic', cuda_device_idx)
RuntimeError: OpenGL 4.4 or later is required
Segmentation fault

I can run triangle.py with cuda just fine, but with --opengl its the same error.

Thanks in advance

s-laine commented 1 year ago

OpenGL/Cuda interop is unfortunately not supported in WSL2. To use the Cuda-based rasterizer in nvdiffrast instead of OpenGL, you can replace RasterizeGLContext with RasterizeCudaContext here in Deep3DFaceRecon_pytorch sources.

adevra commented 1 year ago

OpenGL/Cuda interop is unfortunately not supported in WSL2. To use the Cuda-based rasterizer in nvdiffrast instead of OpenGL, you can replace RasterizeGLContext with RasterizeCudaContext here in Deep3DFaceRecon_pytorch sources.

Works perfectly now. I think Deep3DFaceRecon has to update it like this. Thanks a lot!