NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.35k stars 144 forks source link

No module named 'OpenGL' #3

Closed cysmith closed 3 years ago

cysmith commented 3 years ago

I've been trying the examples. Everything works great except displaying the images. I am able to generate the videos. I get an error on line 69 of samples/torch/util.py saying:

~/PycharmProjects/nvdiffrast$ sudo bash run_sample.sh ./samples/torch/pose.py --outdir samples_output --display-interval 1
Using container image: gltorch:latest
Running command: ./samples/torch/pose.py --outdir samples_output --display-interval 1
Saving results under samples_output/pose
Mesh has 12 triangles and 24 vertices.
rep=0,iter=0,err=50.853275,err_best=50.853275,loss=0.153916,loss_best=0.153916,lr=0.010000,nr=1.000000
Traceback (most recent call last):
  File "./samples/torch/pose.py", line 290, in <module>
    main()
  File "./samples/torch/pose.py", line 281, in main
    mp4save_fn='progress.mp4'
  File "./samples/torch/pose.py", line 243, in fit_pose
    util.display_image(result_image, size=display_res, title='(%d) %d / %d' % (rep, it, max_iter))
  File "/app/samples/torch/util.py", line 69, in display_image
    import OpenGL.GL as gl
ModuleNotFoundError: No module named 'OpenGL'

I tried adding pip install PyOpenGL to Dockerfile but it caused another error. Then I tried replacing util.display_image with OpenCV imshow using a few different versions but this caused errors and does not seem a good direction.

nurpax commented 3 years ago

Hi @cysmith, the --display-interval parameter doesn't work in Docker, this something we should've mentioned in the documentation. Opening interactive windows from within Docker is not impossible but tricky, and I didn't include this functionality in the Docker run instructions or Docker image.

Matplotlib or imshow might be easier to get working but you probably need to make some changes to how run_sample.sh invokes Docker to enable Docker to open windows on your host system.

This blog post might be helpful if you want to play with this yourself: https://developer.nvidia.com/blog/gpu-containers-runtime/. See section "OpenGL Graphics Container" that launches the nbody CUDA sample in a window.

cysmith commented 3 years ago

I see. Thanks for the info. I will try these options and then try to get it working outside Docker.