GroundingDINO icon indicating copy to clipboard operation
GroundingDINO copied to clipboard

Installation ok but _C error

Open FabioColombo1967 opened this issue 1 year ago • 3 comments

RTX 4060

Installation ok (ToMarketNew) C:\ProgettiPy\GroundingDINO>pip install -e . Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com Obtaining file:///C:/ProgettiPy/GroundingDINO Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build editable ... done Preparing editable metadata (pyproject.toml) ... done Requirement already satisfied: torch in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (2.5.1+cu118) Requirement already satisfied: torchvision in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (0.20.1+cu118) Requirement already satisfied: transformers in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (4.46.3) Requirement already satisfied: addict in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (2.4.0) Requirement already satisfied: yapf in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (0.43.0) Requirement already satisfied: timm in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (1.0.11) Requirement already satisfied: numpy in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (1.26.3) Requirement already satisfied: opencv-python in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (4.10.0.84) Requirement already satisfied: supervision>=0.22.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (0.25.0) Requirement already satisfied: pycocotools in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from groundingdino==0.1.0) (2.0.8) Requirement already satisfied: contourpy>=1.0.7 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (1.3.1) Requirement already satisfied: defusedxml<0.8.0,>=0.7.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (0.7.1) Requirement already satisfied: matplotlib>=3.6.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (3.9.3) Requirement already satisfied: pillow>=9.4 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (10.2.0) Requirement already satisfied: pyyaml>=5.3 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (6.0.2) Requirement already satisfied: scipy<2.0.0,>=1.10.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from supervision>=0.22.0->groundingdino==0.1.0) (1.14.1) Requirement already satisfied: huggingface_hub in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from timm->groundingdino==0.1.0) (0.26.3) Requirement already satisfied: safetensors in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from timm->groundingdino==0.1.0) (0.4.5) Requirement already satisfied: filelock in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (3.13.1) Requirement already satisfied: typing-extensions>=4.8.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (4.9.0) Requirement already satisfied: networkx in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (3.2.1) Requirement already satisfied: jinja2 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (3.1.3) Requirement already satisfied: fsspec in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (2024.2.0) Requirement already satisfied: sympy==1.13.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from torch->groundingdino==0.1.0) (1.13.1) Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from sympy==1.13.1->torch->groundingdino==0.1.0) (1.3.0) Requirement already satisfied: packaging>=20.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from transformers->groundingdino==0.1.0) (24.2) Requirement already satisfied: regex!=2019.12.17 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from transformers->groundingdino==0.1.0) (2024.11.6) Requirement already satisfied: requests in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from transformers->groundingdino==0.1.0) (2.32.3) Requirement already satisfied: tokenizers<0.21,>=0.20 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from transformers->groundingdino==0.1.0) (0.20.3) Requirement already satisfied: tqdm>=4.27 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from transformers->groundingdino==0.1.0) (4.67.1) Requirement already satisfied: platformdirs>=3.5.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from yapf->groundingdino==0.1.0) (4.3.6) Requirement already satisfied: cycler>=0.10 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (4.55.0) Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (1.4.7) Requirement already satisfied: pyparsing>=2.3.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (3.2.0) Requirement already satisfied: python-dateutil>=2.7 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (2.9.0.post0) Requirement already satisfied: colorama in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from tqdm>=4.27->transformers->groundingdino==0.1.0) (0.4.6) Requirement already satisfied: MarkupSafe>=2.0 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from jinja2->torch->groundingdino==0.1.0) (2.1.5) Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from requests->transformers->groundingdino==0.1.0) (3.4.0) Requirement already satisfied: idna<4,>=2.5 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from requests->transformers->groundingdino==0.1.0) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from requests->transformers->groundingdino==0.1.0) (2.2.3) Requirement already satisfied: certifi>=2017.4.17 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from requests->transformers->groundingdino==0.1.0) (2024.8.30) Requirement already satisfied: six>=1.5 in c:\users\fabio\anaconda3\envs\tomarketnew\lib\site-packages (from python-dateutil>=2.7->matplotlib>=3.6.0->supervision>=0.22.0->groundingdino==0.1.0) (1.16.0) Building wheels for collected packages: groundingdino Building editable for groundingdino (pyproject.toml) ... done Created wheel for groundingdino: filename=groundingdino-0.1.0-0.editable-py3-none-any.whl size=11107 sha256=f6a5f95e8aa86b70ea2dd438a52fec2ceb61f4002c8c7a48bb76011444db943e Stored in directory: C:\Users\fabio\AppData\Local\Temp\pip-ephem-wheel-cache-n6a4dh7_\wheels\bb\96\49\25741c9a26f93cd122c580b1b7012daebd968cfb6381dde8cb Successfully built groundingdino Installing collected packages: groundingdino Attempting uninstall: groundingdino Found existing installation: groundingdino 0.1.0 Uninstalling groundingdino-0.1.0: Successfully uninstalled groundingdino-0.1.0 Successfully installed groundingdino-0.1.0

but inference _C error

(ToMarketNew) C:\ProgettiPy\GroundingDINO>python demo/inference_on_a_image.py -c groundingdino/config/GroundingDINO_SwinT_OGC.py -p groundingdino_swint_ogc.pth -i Image.jpg -o "product" -t "product" C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\timm\models\layers_init_.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning) C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\ms_deform_attn.py:31: 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!") C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\functional.py:534: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:3596.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] final text_encoder_type: bert-base-uncased C:\ProgettiPy\GroundingDINO\demo\inference_on_a_image.py:77: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. checkpoint = torch.load(model_checkpoint_path, map_location="cpu") _IncompatibleKeys(missing_keys=[], unexpected_keys=['label_enc.weight', 'bert.embeddings.position_ids']) C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\transformers\modeling_utils.py:1161: FutureWarning: The device argument is deprecated and will be removed in v5 of Transformers. warnings.warn( C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch_dynamo\eval_frame.py:632: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.5 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants. return fn(*args, **kwargs) C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\utils\checkpoint.py:87: UserWarning: None of the inputs have requires_grad=True. Gradients will be None warnings.warn( Traceback (most recent call last): File "C:\ProgettiPy\GroundingDINO\demo\inference_on_a_image.py", line 201, in boxes_filt, pred_phrases = get_grounding_output( ^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\demo\inference_on_a_image.py", line 94, in get_grounding_output outputs = model(image[None], captions=[caption]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\groundingdino.py", line 327, in forward hs, reference, hs_enc, ref_enc, init_box_proposal = self.transformer( ^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\transformer.py", line 258, in forward memory, memory_text = self.encoder( ^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\transformer.py", line 576, in forward output = checkpoint.checkpoint( ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch_compile.py", line 32, in inner return disable_fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch_dynamo\eval_frame.py", line 632, in _fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\utils\checkpoint.py", line 489, in checkpoint return CheckpointFunction.apply(function, preserve, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\autograd\function.py", line 575, in apply return super().apply(*args, **kwargs) # type: ignore[misc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\utils\checkpoint.py", line 264, in forward outputs = run_function(*args) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\transformer.py", line 785, in forward src2 = self.self_attn( ^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\nn\modules\module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\ms_deform_attn.py", line 338, in forward output = MultiScaleDeformableAttnFunction.apply( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\fabio\anaconda3\envs\ToMarketNew\Lib\site-packages\torch\autograd\function.py", line 575, in apply return super().apply(*args, **kwargs) # type: ignore[misc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ProgettiPy\GroundingDINO\groundingdino\models\GroundingDINO\ms_deform_attn.py", line 53, in forward output = _C.ms_deform_attn_forward( ^^ NameError: name '_C' is not defined

_C not created

(ToMarketNew) C:\ProgettiPy\GroundingDINO>dir _c /s/p Il volume nell'unità C è Windows Numero di serie del volume: 002C-984A File non trovato

Someone may help?

Thanks in advice

FabioColombo1967 avatar Dec 02 '24 16:12 FabioColombo1967

When "pip install -e . " , is installed exactly, it will create _C.cpython.so file. Then, you should try cd to the main.py file, try python -c " from groundingdino import _C" . If it can not do it, then try to move the _C.so file to which folder that can do the line code, then you will not met the name '_C' issue again.

NamThanhLe1907 avatar Jan 28 '25 08:01 NamThanhLe1907

Same issues, Use an earlier version of torch or upgrade GCC,torch 2.6 , gcc 9 is required on my server, torch 2.1.0 cuda 12.1 gcc 4.5

Installing collected packages: groundingdino
  Running setup.py develop for groundingdino
Successfully installed groundingdino

wang-jinghui avatar Feb 13 '25 06:02 wang-jinghui

your model weights is not uploaded properly please check your model weight path and make sure you have download the weights.

umarcsit avatar Mar 13 '25 19:03 umarcsit