Grounded-Segment-Anything
Grounded-Segment-Anything copied to clipboard
Error: name '_C' is not defined , UserWarning: Failed to load custom C++ ops. Running on CPU mode Only!
torch version: 2.0.1 cuda version: 11.6
Successfully installed groundingdino-0.1.0
when i run grounding_dino_demo
python grounding_dino_demo.py
NameError: name '_C' is not defined UserWarning: Failed to load custom C++ ops. Running on CPU mode Only! warnings.warn("Failed to load custom C++ ops. Running on CPU mode Only!")
I was wondering if you set CUDA_HOME
before installing Grounding-DINO?
I was wondering if you set
CUDA_HOME
before installing Grounding-DINO?
yes, I set CUDA_HOME, still got the same error
I also had this problem, for me it was caused by groundingdino
not being correctly installed. I solved it by finding a corrupted package in the environment, deleting and reinstalling it, then deleting and reinstalling groundingdino
. Other reasons I could think of why it would fail would be if your system c++ compiler is not compatible with the cuda version. You should check the output of installing the package and see if it helps. There are also many other issues recorded for this in the package, you may find those helpful.
There are many other reasons why an installation would not be successful so your mileage may vary.
I also had this problem, for me it was caused by
groundingdino
not being correctly installed. I solved it by finding a corrupted package in the environment, deleting and reinstalling it, then deleting and reinstallinggroundingdino
. Other reasons I could think of why it would fail would be if your system c++ compiler is not compatible with the cuda version. You should check the output of installing the package and see if it helps. There are also many other issues recorded for this in the package, you may find those helpful.There are many other reasons why an installation would not be successful so your mileage may vary.
@villekuosmanen Do you happen to remember which package was corrupted? The reason why I'm asking is that all the installation steps are successful for me, but still, I get the _C error when trying to run grounding dino.
for those who still have this error. maybe you can first run the python setup.py install
after cd to GroundingDINO
. Then if an error is encountered, e.g., fatal error C1083
, you should install the Win10/11 SDK using the Visual Studio installer
i did:
set BUILD_WITH_CUDA=True
set CUDA_HOME="path"
set AM_I_DOCKER=False
cd groundingdino
python setup.py build
python setup.py install
https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/450#issuecomment-1949315114
I have encountered this issue while using Docker, but not otherwise. However, I have managed to fix it on my end.
When the script is trying to run
Grounded-Segment-Anything/GroundingDINO/setup.py
to compile the custom C++ operations, there was an error:[Errno 2] No such file or directory: '/usr/local/cuda/bin/nvcc'
so I checked
ls /usr/local/
in my Docker container and found there was no cuda directory at allbin etc games include lib man sbin share src
even though running the same command outside the container showed additional directories, including
bin cuda cuda-12 cuda-12.2 cuda-9.0 dcgm etc games include lib man sbin share src
Solution: add the line
-v /usr/local/cuda-12.2:/usr/local/cuda:ro \
to the run command inMakefile
, as shown belowdocker run --gpus all -it --rm --net=host --privileged \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v "${PWD}":/home/appuser/working_dir \ -v /usr/local/cuda-12.2:/usr/local/cuda:ro \ -e DISPLAY=$DISPLAY \ --name=gsa \ --ipc=host -it gsa:v0
and don't forget to set your
ENV CUDA_HOME /usr/local/cuda/
correctly inDockerfile
.
i did:
set BUILD_WITH_CUDA=True set CUDA_HOME="path" set AM_I_DOCKER=False cd groundingdino python setup.py build python setup.py install
This solved for me. Thanks!
for those who still have this error. maybe you can first run the
python setup.py install
after cd toGroundingDINO
. Then if an error is encountered, e.g.,fatal error C1083
, you should install the Win10/11 SDK using the Visual Studio installer
you are the best!! thank u so much!! love u !!