GroundingDINO icon indicating copy to clipboard operation
GroundingDINO copied to clipboard

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

Open alex-conanec opened this issue 1 year ago • 8 comments

When I run : from groundingdino.models import build_model

I got this warning saying that I do not have access to GPU : UserWarning: Failed to load custom C++ ops. Running on CPU mode Only!

But, when I check with pytorch by running: torch.device('cuda' if torch.cuda.is_available() else 'cpu')

I get "cuda".

What is weird, is that I don't have this problem on google collab, but I do have it on the server of my laboratory. So what's wrong ?

alex-conanec avatar Jun 21 '23 09:06 alex-conanec

I have the same problem. However, when I rerun it this warning disappeared.

Mohamed2519 avatar Jun 22 '23 10:06 Mohamed2519

Yes I saw that as well. But it appears even in the case of CPU. So the problem is not the warning, but the fact that the model will use GPU. Have you tried to compare the performance of the model with and without the warning ?

alex-conanec avatar Jun 22 '23 12:06 alex-conanec

You should set CUDA_HOME before running the compiling for custom operator, you can check if there're CUDA_HOME be set in your env~

rentainhe avatar Jun 23 '23 16:06 rentainhe

Thank you for you answer, I had indeed not set the CUDA_HOME variable in my environment. But still, i got the warning...

Could it comes from somewhere else ? Or maybe I need to re-install everything after having set the environmental variable CUDA_HOME ?

alex-conanec avatar Jun 26 '23 11:06 alex-conanec

I get this warning even if I set CUDA_HOME. But, I am using the CUDA Docker image so I am not sure if anyone else gets it in the Docker image.

SSdevelop avatar Sep 20 '23 16:09 SSdevelop

I get this warning even if I set CUDA_HOME. But, I am using the CUDA Docker image so I am not sure if anyone else gets it in the Docker image.

I experience the same issue with CUDA Docker image. Did you find a solution?

viktorpovazhuk avatar Oct 19 '23 07:10 viktorpovazhuk

I experience the same issue with CUDA Docker image. Did you find a solution?

I run this script for my backend inside the container:

# !/bin/bash

if [ -d /app/model/GroundingDINO/ ]; then
    echo "Files for GroundingDINO exists. Installing GroundingDINO"
    cd /app/model/GroundingDINO/
    pip install -e .
    cd /app
else
    echo "Files for GroundingDINO does not exists. Downloading GroundingDINO"
    cd /app/model
    git clone https://github.com/IDEA-Research/GroundingDINO.git
    cd GroundingDINO
    echo "Installing GroundingDINO"
    pip install -e .
    cd /app
fi

if ! [ -d /app/model/GroundingDINO/weights ]; then
    echo "Downloading weights for GroundingDINO"
    cd /app/model/GroundingDINO/
    mkdir weights
    cd weights
    wget wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
    cd /app
fi

For some reason I have to manually install GroundingDino inside the container. I am not a big Docker expert. So if anyone knows why that happens please let me know.

SSdevelop avatar Oct 19 '23 13:10 SSdevelop

I was able to build docker with CUDA using the following image @viktorpovazhuk @SSdevelop https://github.com/IDEA-Research/GroundingDINO/pull/307

teenaxta avatar Mar 08 '24 16:03 teenaxta