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

I have problem about nvdiffrast_plugin_gl.so #92

Closed
JiyouSeo opened this issue Sep 15, 2022 · 10 comments
Closed

I have problem about nvdiffrast_plugin_gl.so #92

JiyouSeo opened this issue Sep 15, 2022 · 10 comments

Comments

@JiyouSeo
Copy link

JiyouSeo commented Sep 15, 2022

Hello, thank you for your great research!

I have a problem running the code that import nvdiffrast.

Traceback (most recent call last):
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1809, in _run_ninja_build
    subprocess.run(
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jiyouseo/nvdiffrec/train.py", line 556, in <module>
    glctx = dr.RasterizeGLContext()
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/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)
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/nvdiffrast/torch/ops.py", line 118, in _get_plugin
    torch.utils.cpp_extension.load(name=plugin_name, sources=source_paths, extra_cflags=opts, extra_cuda_cflags=opts+['-lineinfo'], extra_ldflags=ldflags, with_cuda=True, verbose=False)
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1202, in load
    return _jit_compile(
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1425, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1537, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1825, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'nvdiffrast_plugin_gl': [1/1] c++ common.o glutil.o rasterize_gl.o torch_bindings_gl.o torch_rasterize_gl.o -shared -lGL -lEGL -L/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/usr/local/cuda-11.3/lib64 -lcudart -o nvdiffrast_plugin_gl.so
FAILED: nvdiffrast_plugin_gl.so 
c++ common.o glutil.o rasterize_gl.o torch_bindings_gl.o torch_rasterize_gl.o -shared -lGL -lEGL -L/home/jiyouseo/anaconda3/envs/dmodel/lib/python3.9/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/usr/local/cuda-11.3/lib64 -lcudart -o nvdiffrast_plugin_gl.so
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lEGL
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

So, I modify ['ninja', '-v'] to ['ninja', '--version'] in cpp_extension.py
Then It return

ImportError:/home/jiyouseo/.cache/torch_extensions/py36_cu113/nvdiffrast_plugin_gl/nvdiffrast_plugin_gl.so: cannot open shared object file: No such file or directory

I guess it is because it cannot build nvdiffrast_plugin_gl.so.
How can I build exactly nvdiffrast_plugin_gl.so?
And this is my code environment.

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.6 LTS
Release:	18.04
Codename:	bionic
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA RTX A6000    On   | 00000000:3B:00.0 Off |                  Off |
| 58%   82C    P2   232W / 300W |  34285MiB / 48685MiB |    100%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  NVIDIA RTX A6000    On   | 00000000:5E:00.0 Off |                  Off |
| 67%   85C    P2   234W / 300W |  33903MiB / 48685MiB |    100%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   2  NVIDIA RTX A6000    On   | 00000000:AF:00.0 Off |                  Off |
| 67%   85C    P2   235W / 300W |  34135MiB / 48685MiB |    100%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   3  NVIDIA RTX A6000    On   | 00000000:D8:00.0 Off |                  Off |
| 61%   84C    P2   232W / 300W |  34101MiB / 48685MiB |    100%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1733      G   /usr/lib/xorg/Xorg                  4MiB |
|    0   N/A  N/A     16354      C   ...onda/envs/uvtr/bin/python    34277MiB |
|    1   N/A  N/A      1733      G   /usr/lib/xorg/Xorg                  4MiB |
|    1   N/A  N/A     16355      C   ...onda/envs/uvtr/bin/python    33895MiB |
|    2   N/A  N/A      1733      G   /usr/lib/xorg/Xorg                  4MiB |
|    2   N/A  N/A     16356      C   ...onda/envs/uvtr/bin/python    34127MiB |
|    3   N/A  N/A      1733      G   /usr/lib/xorg/Xorg                  4MiB |
|    3   N/A  N/A     16357      C   ...onda/envs/uvtr/bin/python    34093MiB |
+-----------------------------------------------------------------------------+

Thank you.

@s-laine
Copy link
Collaborator

s-laine commented Sep 15, 2022

You seem to have no graphics libraries installed on your system (OpenGL and EGL) that are required by the OpenGL-based rasterizer. I suggest you take a look at our Dockerfile to see the required libraries and environment variables, or even better, use the Docker environment directly. Note that you will also need the OS-level graphics drivers installed in the system.

Since version v0.3.0 nvdiffrast includes a Cuda-based rasterizer that doesn't require the graphics libraries or drivers. It has some restrictions compared to OpenGL (see documentation) but it could be a working solution in your use case.

@JiyouSeo
Copy link
Author

Thank you for kindly replying. I will do following your reply.

@L-Aidan
Copy link

L-Aidan commented Nov 1, 2022

Hello, I have the same problem as you, have you solved it?

@L-Aidan
Copy link

L-Aidan commented Nov 1, 2022

I have replaced "RasterizeGLContext" with "RasterizeCudaContext", so I guess I don't need to install graphics libraries like OpenGL,but the problem is still there.

@harlanhong
Copy link

I have replaced "RasterizeGLContext" with "RasterizeCudaContext", so I guess I don't need to install graphics libraries like OpenGL,but the problem is still there.

Which line did you modify? I met the same problem.

@L-Aidan
Copy link

L-Aidan commented Nov 2, 2022

I did the same thing as JiyouSeo, I modified ['ninja', '-v'] to ['ninja', '--version'] in cpp_extension.py ,and then I got "nvdiffrast_plugin_gl.so: cannot open shared object file: No such file or directory".

@L-Aidan
Copy link

L-Aidan commented Nov 2, 2022

It seems that I have solved this problem:don't modify " ['ninja', '-v']", and replace "RasterizeGLContext" with "RasterizeCudaContext" in your project.

@harlanhong
Copy link

harlanhong commented Nov 2, 2022

It seems that I have solved this problem:don't modify " ['ninja', '-v']", and replace "RasterizeGLContext" with "RasterizeCudaContext" in your project.

in util/nvdiffrast.py? it does not work for me.

@L-Aidan
Copy link

L-Aidan commented Nov 2, 2022

in util/nvdiffrast.py? it does not work for me.

It should be in some files which import nvdiffrast, I think you will find it by searching "RasterizeGLContext" in your own project.
By the way, if you want to use "RasterizeGLContext", you must install some related libs following the DockerFile

@RyanbowZ
Copy link

RyanbowZ commented Apr 7, 2024

Here's a new update on this issue:
If you already installed ninja and tried all the above-mentioned methods but still suffer from this problem, you can check whether you have installed ninja both on python and ubuntu environment. Installing both of them will cause conflict!
I tried almost every other approach on the Internet, until finally I resolved this by:
pip uninstall ninja
And I suggest not change anything under system directories, the suggested methods of modifying ['ninja', '-v'] to ['ninja', '--version'] in cpp_extension.py might be just a way of shifting between the ubuntu and python's versions of ninja.

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

5 participants