IDEA-Research / Grounded-Segment-Anything

Grounded SAM: Marrying Grounding DINO with Segment Anything & Stable Diffusion & Recognize Anything - Automatically Detect , Segment and Generate Anything
https://arxiv.org/abs/2401.14159
Apache License 2.0
15.16k stars 1.4k forks source link

请问可以在华为昇腾服务器上使用吗?没有cuda #372

Open jwb2021 opened 1 year ago

jwb2021 commented 1 year ago

您好,我现在使用的是华为昇腾服务器Ascend: 4*Ascend 910。没有GPU,而是NPU,环境是mindspore1.8.0-cann5.1.2-py3.7-euler2.8.3。但是现在在调试的时候无法运行demo,您能给我些帮助吗?

jwb2021 commented 1 year ago

我的python=3.7.10 torch=1.11.0 torchvision=0.12.0. 我尝试安装过python3.8但是这个服务器好像不支持过高的版本。

rentainhe commented 1 year ago

我的python=3.7.10 torch=1.11.0 torchvision=0.12.0. 我尝试安装过python3.8但是这个服务器好像不支持过高的版本。

python 3.8 应该可以运行 grounded-sam, 我们自己用的环境也可以跑3.8的, torch 1.11 的话应该也可以,如果可以顺利编译Deformable-Attention算子的话就行

jwb2021 commented 1 year ago

我在我电脑上测试了py3.7+torch1.11+cu113,是没问题的。放在服务器反而不行了,现在在查原因。谢谢您的回复

rentainhe commented 1 year ago

我在我电脑上测试了py3.7+torch1.11+cu113,是没问题的。放在服务器反而不行了,现在在查原因。谢谢您的回复

您是会报错吗,注意一下Deformable算子无法像cuda:1这样指定固定device,可能会输出空的结果

jwb2021 commented 1 year ago

是会报错,错误信息大概是这样: NonZero Traceback (most recent call last): File "grounded_sam_demo.py", line 190, in model, image, text_prompt, box_threshold, text_threshold, device=device File "grounded_sam_demo.py", line 63, in get_grounding_output outputs = model(image[None], captions=[caption]) File "/home/ma-user/anaconda3/envs/python-3.7.10/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/ma-user/work/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/models/GroundingDINO/groundingdino.py", line 242, in forward tokenized, self.specical_tokens, self.tokenizer File "/home/ma-user/work/Grounded-Segment-Anything-main/GroundingDINO/groundingdino/models/GroundingDINO/bertwarper.py", line 240, in generate_masks_with_special_tokens_and_transfer_map idxs = torch.nonzero(special_tokens_mask) RuntimeError: Run:/usr1/workspace/FPTA_Daily_open_pytorchv1.11.0-5.0.rc1/CODE/torch_npu/csrc/framework/OpParamMaker.cpp:138 NPU error,NPU error code is:507018

因为我使用的是NPU,所以我只是简单的把device指定为了npu:0,如下 python grounded_sam_demo.py --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py --grounded_checkpoint groundingdino_swint_ogc.pth --sam_checkpoint sam_vit_h_4b8939.pth --input_image assets/demo1.jpg --output_dir "outputs" --box_threshold 0.3 --text_threshold 0.25 --text_prompt "bear" --device "npu:0"

问题是出在指定设备错误上吗?请问这样的话该如何修改呢?

rentainhe commented 1 year ago

无法指定--device "cuda"吗,这个我不确定Deformable算子能否正常编译

jwb2021 commented 1 year ago

有无平台限制,无法安装cuda,只能使用他们的卡。我再看看如何在npu下编译Deformable吧,谢谢您