-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
error: (-217:Gpu API call) invalid device function in function 'make_policy' #20778
Copy link
Copy link
Closed
Closed
Copy link
Labels
category: dnncategory: gpu/cuda (contrib)OpenCV 4.0+: moved to opencv_contribOpenCV 4.0+: moved to opencv_contribquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.orgask questions and other "no action" items here: https://forum.opencv.org
Milestone
Description
System information (version)
- OpenCV => 4.5.3-dev
- Operating System / Platform => Ubuntu 18.04 / Jetson AGX Xavier
- Compiler => python3
Detailed description
I have compiled opencv with cuda and tried to run an object detection program but it returned an error. Cuda 10.2 is installed. May I know how do I fix this?
Thanks
Steps to reproduce
This is the code that I am trying to run with my camera:
import cv2
import numpy as np
import matplotlib.pyplot as plt
config_file = '/home/user/Desktop/Object_Detection/ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
frozen_model = '/home/user/Desktop/Object_Detection/frozen_inference_graph.pb'
model = cv2.dnn_DetectionModel(frozen_model, config_file)
model.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
model.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
classlabels = []
file_name = '/home/user/Desktop/Object_Detection/Labels.txt'
with open(file_name, 'rt') as fpt:
classLabels = fpt.read().rstrip('\n').split('\n')
model.setInputSize(320,320)
model.setInputScale(1.0/127.5)
model.setInputMean((127.5,127.5,127.5))
model.setInputSwapRB(True)
#ClassIndex, confidence, bbox = model.detect(img.confThreshold = 0.5)
# set font
font_scale = 3
font = cv2.FONT_HERSHEY_PLAIN
# initiate video
cv2.startWindowThread()
cap = cv2.VideoCapture(2)
# filter class objects
filt = np.zeros(80)
filt[0] = 1;
while True:
ret, frame = cap.read()
ClassIndex, confidence, bbox = model.detect(frame, confThreshold = 0.55)
#print(ClassIndex)
if (len(ClassIndex)!=0):
for ClassInd, conf, boxes in zip(ClassIndex.flatten(), confidence.flatten(), bbox):
if (ClassInd==1):
cv2.rectangle(frame, boxes, (255,0,0), 2)
cv2.putText(frame, classLabels[ClassInd-1], (boxes[0]+10, boxes[1]+40), font, fontScale = font_scale, color = (0,255,0), thickness = 3)
cv2.imshow('Detected objects', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
The error:
Traceback (most recent call last):
File "run_video.py", line 42, in <module>
ClassIndex, confidence, bbox = model.detect(frame, confThreshold = 0.55)
cv2.error: OpenCV(4.5.3-dev) /home/user/opencv/modules/dnn/src/cuda/execution.hpp:52: error: (-217:Gpu API call) invalid device function in function 'make_policy'
and build information for cuda:
NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 70
NVIDIA PTX archs:
cuDNN: YES (ver 8.0.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category: dnncategory: gpu/cuda (contrib)OpenCV 4.0+: moved to opencv_contribOpenCV 4.0+: moved to opencv_contribquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.orgask questions and other "no action" items here: https://forum.opencv.org