当前位置:   article > 正文

运行Grounded-Segment-Anything警告:Failed to load custom C++ ops. Running on CPU mode Only!_userwarning: failed to load custom c++ ops. runnin

userwarning: failed to load custom c++ ops. running on cpu mode only!

Github项目地址:https://github.com/IDEA-Research/Grounded-Segment-Anything

按照GitHub上install without Docker部署后,运行demo时弹出警告:

Usemamning: failed to toad custan C++ ops. Rumning on cpu mode anly!warnings.warn("Failed to load custom C++ ops. Running on CPu mode 0nly!")

开始以为是哪里没有装好,又重装了一遍,还是不行。

尝试用pip check查找有没有冲突的依赖,解决冲突后仍然无法用GPU运行。

解决办法是:

用Docker部署

这时我在Makefile中发现了这样一句:

  1. # This solves https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/53
  2. # and https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/84

所以还是用Docker部署方便。

租用的云GPU不知道为什么在用Docker部署完成之后,运行demo提示:

  1. CUDA not installed is not supported
  2. docker build --build-arg USE_CUDA=0 \
  3. --build-arg TORCH_ARCH= \

也就是自动去构建一个不使用CUDA的Docker镜像,如果想使用GPU需要去修改Makefile文件,把USE_CUDA := 0改成1, NVCC_VRSION := ''not installed"改成"default",修改后的文件:

  1. # Get version of CUDA and enable it for compilation if CUDA > 11.0
  2. # This solves https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/53
  3. # and https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/84
  4. # when running in Docker
  5. # Check if nvcc is installed
  6. NVCC := $(shell which nvcc)
  7. ifeq ($(NVCC),)
  8. # NVCC not found
  9. USE_CUDA := 1
  10. NVCC_VERSION := "default"
  11. else
  12. NVCC_VERSION := $(shell nvcc --version | grep -oP 'release \K[0-9.]+')
  13. USE_CUDA := $(shell echo "$(NVCC_VERSION) > 11" | bc -l)
  14. endif
  15. # Add the list of supported ARCHs
  16. ifeq ($(USE_CUDA), 1)
  17. TORCH_CUDA_ARCH_LIST := "3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX"
  18. BUILD_MESSAGE := "I will try to build the image with CUDA support"
  19. else
  20. TORCH_CUDA_ARCH_LIST :=
  21. BUILD_MESSAGE := "CUDA $(NVCC_VERSION) is not supported"
  22. endif
  23. build-image:
  24. @echo $(BUILD_MESSAGE)
  25. docker build --build-arg USE_CUDA=$(USE_CUDA) \
  26. --build-arg TORCH_ARCH=$(TORCH_CUDA_ARCH_LIST) \
  27. -t gsa:v0 .
  28. run:
  29. ifeq (,$(wildcard ./sam_vit_h_4b8939.pth))
  30. wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
  31. endif
  32. ifeq (,$(wildcard ./groundingdino_swint_ogc.pth))
  33. wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
  34. endif
  35. docker run --gpus all -it --rm --net=host --privileged \
  36. -v /tmp/.X11-unix:/tmp/.X11-unix \
  37. -v "${PWD}":/home/appuser/working_dir \
  38. -e DISPLAY=$DISPLAY \
  39. --name=gsa \
  40. --ipc=host -it gsa:v0

之后可以构建使用GPU的镜像

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/447743
推荐阅读
相关标签