Dlib cuda人脸检测.dat模型在GTX 1650上崩溃,而在其他许多gpu设备上则表现出色 代码运行命令正确的输出输出错误唯一的区别

问题描述

我得到了与下面相同的Dockerfile和相同的代码,但结果不同

一个给出正确的打印输出,而另一个崩溃而没有任何消息!

代码

import dlib
import cv2
print(dlib.__version__)  # 19.17.99,the same

cnn_face_detector = dlib.cnn_face_detection_model_v1('mmod_human_face_detector.dat')

img = cv2.imread("1.jpg")    

rects = cnn_face_detector(img,1)  # one crashes every time on this line
print("Number of faces detected: {}".format(len(rects))) 

for i,d in enumerate(rects):
    face = d.rect
    print("Detection {}: Left: {} Top: {} Right: {} Bottom: {} Confidence: {}".format(i,face.left(),face.top(),face.right(),d.rect.bottom(),d.confidence))

    cv2.rectangle(img,(face.left(),face.top()),(face.right(),face.bottom()),(0,255),2)

运行命令

nvidia-docker run -it --rm -w="/usr/src/app" -v $(pwd):/usr/src/app myDocEnv test.py

正确的输出

19.17.99
Number of faces detected: 1
Detection 0: Left: 245 Top: 100 Right: 415 Bottom: 269 Confidence: 1.079284906387329

输出错误

19.17.99

唯一的区别

它们之间的唯一区别是GPU硬件设备

崩溃的人使用 GeForce GTX 1650 P620 1050Ti

上运行时不会出现问题

解决方法

RUN mkdir -p /usr/local/cuda/nccl/lib && \
         ln -sf /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/nccl/lib/ &&\
         ln -sf /usr/lib/x86_64-linux-gnu/libcudnn.so.7 /usr/local/cuda/lib64/
RUN apt-get update && apt-get install -y --no-install-recommends \
         libcublas10 \
         libcublas-dev
RUN apt install -y libprotobuf-dev protobuf-compiler

RUN export CUDA_cublas_LIBRARY=/usr/local/cuda-10.2/targets/x86_64-linux/lib/libcublas.so

添加这些东西解决了我的问题

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...