Grounded-Segment-Anything icon indicating copy to clipboard operation
Grounded-Segment-Anything copied to clipboard

Failed to load custom C++ ops. Running on CPU mode Only!

Open liujiadong369 opened this issue 1 year ago • 12 comments

b a How to solve this error? python 3.9 torch 1.13.1+cu116 torchaudio 0.13.1+cu116 torchvision 0.14.1+cu116 linux Thank you very much!!

liujiadong369 avatar Apr 17 '23 09:04 liujiadong369

你可以这样子安装,pip install https://github.com/IDEA-Research/GroundingDINO/archive/refs/tags/v0.1.0-alpha2.tar.gz

tuofeilunhifi avatar Apr 17 '23 09:04 tuofeilunhifi

Can you check if there's any file with name similar to this groundingdino/_C.cpython-310-x86_64-linux-gnu.so basically starting with _C , in setup.py this particular extension is build as seen here ext_modules = [ extension( "groundingdino._C", sources, include_dirs=include_dirs, define_macros=define_macros, extra_compile_args=extra_compile_args, ) ]

If it doesn't gets build properly you will face error while loading or building the model, in order to build it properly you should have nvidia toolkit supporting your pythorch version in your case it's 11.6

TestPrab avatar Apr 18 '23 10:04 TestPrab

https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/15 address this problem by looking at this one

bofei5675 avatar Apr 19 '23 03:04 bofei5675

Have you handled this problem yet? If you have some solutions, could you please tell me, because I'm still being turtured by this problem for a week.Besides I tried to pip install https://github.com/IDEA-Research/GroundingDINO/archive/refs/tags/v0.1.0-alpha2.tar.gz, but this does not work at all. QAQ

ChenSteventx avatar Jun 15 '23 06:06 ChenSteventx

@ChenSteventx This problem is cuased by the cuda version your torch compiled on is different to the one on your current device.

For example, you can check your current python environment

>>> import torch
>>> torch.version.cuda
'11.7'

And you can check your computer's current version:

ls /usr/local/
>>> bin  cuda   cuda-12

This is an example on my computer (Ubuntu 22). To address this problem, I need to match the version of cuda with my torch, so that install from source code can work( which give you correct output from C code something like _C.cpython-310-x86_64-linux-gnu.so)

Therefore, I follow the instruction here to install extra version of cuda on my machine. After this step, my machine looks like:

ls /usr/local/
>>> bin  cuda   cuda-12 cuda-11.7

Then, I did

CUDA_HOME=/usr/local/cuda-11.7 pip install https://github.com/IDEA-Research/GroundingDINO/archive/refs/tags/v0.1.0-alpha2.tar.gz

Which solve my issue.

bofei5675 avatar Jun 15 '23 07:06 bofei5675

In my case the problem was caused by ABI incompatibility. System GCC was used at building time, but python binary comes from conda. Installing gcc/gxx from conda solves the issue:

conda install gcc_linux-64
conda install gxx_linux-64

Mehanik avatar Dec 26 '23 11:12 Mehanik

In my case the problem was caused by ABI incompatibility. System GCC was used at building time, but python binary comes from conda. Installing gcc/gxx from conda solves the issue:

conda install gcc_linux-64
conda install gxx_linux-64

As this command will install the latest version of gcc/gcc, which may not be compatible with this project(I failed to build using this command). Instead, I restrict the installation version as below and achieve success.

conda install gcc_linux-64==9.3.0
conda install gxx_linux-64==9.3.0

Big-Brother-Pikachu avatar Jan 31 '24 09:01 Big-Brother-Pikachu

@ChenSteventx This problem is cuased by the cuda version your torch compiled on is different to the one on your current device.

For example, you can check your current python environment

>>> import torch
>>> torch.version.cuda
'11.7'

And you can check your computer's current version:

ls /usr/local/
>>> bin  cuda   cuda-12

This is an example on my computer (Ubuntu 22). To address this problem, I need to match the version of cuda with my torch, so that install from source code can work( which give you correct output from C code something like _C.cpython-310-x86_64-linux-gnu.so)

Therefore, I follow the instruction here to install extra version of cuda on my machine. After this step, my machine looks like:

ls /usr/local/
>>> bin  cuda   cuda-12 cuda-11.7

Then, I did

CUDA_HOME=/usr/local/cuda-11.7 pip install https://github.com/IDEA-Research/GroundingDINO/archive/refs/tags/v0.1.0-alpha2.tar.gz

Which solve my issue.

solved 。 thanks!!

sunmonk avatar Mar 14 '24 05:03 sunmonk

This can be solved by building the Dockerfile using the Makefile. The argument to the Dockerfile should be as follows:

ARG USE_CUDA=1 ARG TORCH_ARCH="3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX" ENV TORCH_CUDA_ARCH_LIST

(I manually specified these in my dockefile) This will generate the necessary files to run grounding dino on GPU.

Praneethcruzon avatar Mar 25 '24 06:03 Praneethcruzon