Grounded-Segment-Anything
Grounded-Segment-Anything copied to clipboard
Failed to load custom C++ ops. Running on CPU mode Only!
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!!
你可以这样子安装,pip install https://github.com/IDEA-Research/GroundingDINO/archive/refs/tags/v0.1.0-alpha2.tar.gz
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
https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/15 address this problem by looking at this one
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 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.
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
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
@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!!
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.