Open alaayousef87 opened 3 years ago
Hi @alaayousef87, could you add the steps to reproduce your issue? Which commands do you use to install gocv with openvino and cuda? make install_openvino
and make install_cuda
?
Hi Thank you for your response,
I use make install_all
Should I do it like that make install_openvino and install_cuda it is not the same when I call make install_all ?
Another question before I use make install openvino should I install the openvino toolkit by installer ? Or the script will also install it for me???
I don’t have any intel gpu so the cldnn option can I keep it enabled in make install openvino? If not what i should use in instead the cpu plugging??
In the makefile in the command to install all for opencv the inference engine path is going to dldt folder ? But how because in the install you do it in openvino folder Can you explain me this point please 🙏
Last question I did another approach:
Build openvino from source with disable gpu plugging and enabled cpu plugging
Build opencv from source with cuda enabled and inferences engine ngraph enable
And all of tha run successfully until here
When I run gocv after source to my custom environment the cuda working but the openvino not seeing the ie version , when I try to apply the command in the cmd openvino ie version give me error intferance engine not found
Thank you
On Wed, 24 Mar 2021 at 12:01 AM Wendel Hime @.***> wrote:
Hi @alaayousef87 https://github.com/alaayousef87, could you add the steps to reproduce your issue? Which commands do you use to install openvino and cuda? make install_openvino and make install_cuda?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hybridgroup/gocv/issues/814#issuecomment-805197877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE73ZBOIXP2JR6QR2VRJDGLTFDXPZANCNFSM4ZQSYE4A .
Hi again:)
I have one update I successfully have now opencv version working perfectly with cuda and with openvino :)) but not in gocv :((
Now in python when I try to run dnn with backend cuda is running perfectly with any models but not openvino model
Also when I run dnn with backend interface engine and cpu target with openvino model also work perfectly
But when I run dnn in openvino model and backend cuda it is not working and I believe that’s something I can’t do without gocv
Now my question is really gocv can do that for me i mean I can run openvino model in cuda backend with gocv ??
Really I appreciate any help answer or comment
Thank you
On Wed, 24 Mar 2021 at 12:01 AM Wendel Hime @.***> wrote:
Hi @alaayousef87 https://github.com/alaayousef87, could you add the steps to reproduce your issue? Which commands do you use to install openvino and cuda? make install_openvino and make install_cuda?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hybridgroup/gocv/issues/814#issuecomment-805197877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE73ZBOIXP2JR6QR2VRJDGLTFDXPZANCNFSM4ZQSYE4A .
Hi @alaayousef87 , could you provide some sample code with a openvino model? This way I can try to reproduce and check what is happening.
Now my question is really gocv can do that for me i mean I can run openvino model in cuda backend with gocv ??
I don't have this answer yet, but I have guess, if it isn't working with python lib, it can be something related directly to OpenCV C++ lib.
Please execute this method to check all available backends and print on response
import cv2
print(cv2.dnn.getAvailableBackends())
Hi,
import cv2 cv2.cuda.getCudaEnabledDeviceCount() 1 print(cv2.dnn.getAvailableBackends()) Traceback (most recent call last): File "
", line 1, in AttributeError: module 'cv2.dnn' has no attribute 'getAvailableBackends'
getAvailableBackends is not in my dnn !! maybe this function for c++ lib not python? My sample code:
ARCH_FPATH_XML="intel/face-detection-retail-0004/FP16/face-detection-retail-0004.xml" MODEL_FPATH_BIN ="intel/face-detection-retail-0004/FP16/face-detection-retail-0004.bin"
net = cv2.dnn.readNet(ARCH_FPATH_XML, MODEL_FPATH_BIN)
print("Loading the model successfully by dnn lets set backend ..")
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
print("Loading the model with backend what is my layers by dnn ..") ln = net.getLayerNames() print(ln)
print("Processing input image...") IMG_FPATH ="firstimg.jpg" frame = cv2.imread(IMG_FPATH) if frame is None: raise Exception(f'Image not found here: {IMG_FPATH}') print("Loading the image with backend set successfully by dnn ..")
blob = cv2.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv2.CV_8U) net.setInput(blob) out = net.forward()
returned error Layer detection_out of type unsupported on OpenCV backend in function forwardLayer my target to solve that error to run openvino model in my cuda backend
if I changed to this 2 line net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE) net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU) it is working correctly with openvino model
the 2 line of setting backend cuda working fine with any other model "not openvino model" example of 100% working code with cuda using yolo:
--output ../output_videos/yolo_janie.avi --yolo yolo-coco --display 0
--output ../output_videos/yolo_janie.avi --yolo yolo-coco --display 0 --use-gpu 1
from imutils.video import FPS import numpy as np import argparse import cv2 import os
ap = argparse.ArgumentParser() ap.add_argument("-i", "--input", type=str, default="", help="path to (optional) input video file") ap.add_argument("-o", "--output", type=str, default="", help="path to (optional) output video file") ap.add_argument("-d", "--display", type=int, default=1, help="whether or not output frame should be displayed") ap.add_argument("-y", "--yolo", required=True, help="base path to YOLO directory") ap.add_argument("-c", "--confidence", type=float, default=0.5, help="minimum probability to filter weak detections") ap.add_argument("-t", "--threshold", type=float, default=0.3, help="threshold when applyong non-maxima suppression") ap.add_argument("-u", "--use-gpu", type=bool, default=0, help="boolean indicating if CUDA GPU should be used") args = vars(ap.parse_args())
labelsPath = os.path.sep.join([args["yolo"], "coco.names"]) LABELS = open(labelsPath).read().strip().split("\n")
np.random.seed(42) COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
weightsPath = os.path.sep.join([args["yolo"], "yolov3.weights"]) configPath = os.path.sep.join([args["yolo"], "yolov3.cfg"])
print("[INFO] loading YOLO from disk...") net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
if args["use_gpu"]:
print("[INFO] setting preferable backend and target to CUDA...") net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
ln = net.getLayerNames() print("[lolo]what is my layers...") print(ln) ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()] print("[lolo]what is my layers. after..") print(ln)
W = None H = None
print("[INFO] accessing video stream...") vs = cv2.VideoCapture(args["input"] if args["input"] else 0) writer = None fps = FPS().start()
while True:
(grabbed, frame) = vs.read()
if not grabbed: break
if W is None or H is None: (H, W) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (416, 416), swapRB=True, crop=False) net.setInput(blob) layerOutputs = net.forward(ln)
boxes = [] confidences = [] classIDs = []
for output in layerOutputs:
for detection in output:
scores = detection[5:] classID = np.argmax(scores) confidence = scores[classID]
if confidence > args["confidence"]:
box = detection[0:4] * np.array([W, H, W, H]) (centerX, centerY, width, height) = box.astype("int")
x = int(centerX - (width / 2)) y = int(centerY - (height / 2))
boxes.append([x, y, int(width), int(height)]) confidences.append(float(confidence)) classIDs.append(classID)
idxs = cv2.dnn.NMSBoxes(boxes, confidences, args["confidence"], args["threshold"])
if len(idxs) > 0:
for i in idxs.flatten():
(x, y) = (boxes[i][0], boxes[i][1]) (w, h) = (boxes[i][2], boxes[i][3])
color = [int(c) for c in COLORS[classIDs[i]]] cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2) text = "{}: {:.4f}".format(LABELS[classIDs[i]], confidences[i]) cv2.putText(frame, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
if args["display"] > 0:
cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF
q
key was pressed, break from the loopif key == ord("q"): break
if args["output"] != "" and writer is None:
fourcc = cv2.VideoWriter_fourcc(*"MJPG") writer = cv2.VideoWriter(args["output"], fourcc, 30, (frame.shape[1], frame.shape[0]), True)
if writer is not None: writer.write(frame)
fps.update()
fps.stop() print("[INFO] elasped time: {:.2f}".format(fps.elapsed())) print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
thank you
On Wed, Mar 24, 2021 at 6:53 PM Wendel Hime @.***> wrote:
Hi @alaayousef87 https://github.com/alaayousef87 , could you provide some sample code with a openvino model? This way I can try to reproduce and check what is happening.
Now my question is really gocv can do that for me i mean I can run openvino model in cuda backend with gocv ??
I don't have this answer yet, but I have guess, if it isn't working with python lib, it can be something related directly to OpenCV C++ lib.
Please execute this method to check all available backends and print on response
import cv2print(cv2.dnn.getAvailableBackends())
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hybridgroup/gocv/issues/814#issuecomment-805886858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE73ZBJL535ZBKO2IVKPWWTTFH4GLANCNFSM4ZQSYE4A .
getAvailableBackends is not in my dnn !! maybe this function for c++ lib not python?
Yeah, I'm really sorry, I was looking at the docs and wasn't expecting this.
Following your error:
Layer detection_out of type unsupported on OpenCV backend in function forwardLayer
It seems that CUDA Backend don't have support to this layer, but looking at OpenCV implementation, this message only raises when preferableBackend
is equal to DNN_BACKEND_OPENCV
which is weird, even if you set your preferable backend it will use DNN_BACKEND_OPENCV
(as defined here). I believe you'll have a better support for this case opening a issue on opencv/opencv
Hi
Thank you so much for your support
I have this error because of this condition it->second.empty because I see it is empty when I trace my code
Anyway the IR model from openvino will ever never run in cuda they are intel and they will run only on intel GPU and cannot run in nvidia GPU , I have this answer after difficult work and I like to share maybe other people will avoid to do that mistake and trying to do something not doable :)
Yes you can have one opencv version with cuda enabled and inference engine for openvino and you can run both of openvino and cuda in same opencv version but when you use the dnn to read and then forward to network You need to use the supported back end to each model
By example yolo can support backend cuda But IR Model from openvino can support cldnn the plugin of intel gpu but will ever never support the nvidia cuda gpu
Even if you try to convert the model to model can support cuda like tesnsorflow by example you can’t, you can convert tensorflow to IR model but you can’t transfer the IR model to tensorflow
This is my conclusion I hope if there is anyone having another information to share it with us
Thank you 🙏
On Wed, 24 Mar 2021 at 9:59 PM Wendel Hime @.***> wrote:
getAvailableBackends is not in my dnn !! maybe this function for c++ lib not python?
Yeah, I'm really sorry, I was looking at the docs and wasn't expecting this.
Following your error:
Layer detection_out of type unsupported on OpenCV backend in function forwardLayer
It seems that CUDA Backend don't have support to this layer, but looking at OpenCV implementation https://github.com/opencv/opencv/blob/master/modules/dnn/src/dnn.cpp#L3183, this message only raises when preferableBackend is equal to DNN_BACKEND_OPENCV which is weird, even if you set your preferable backend it will use DNN_BACKEND_OPENCV (as defined here https://github.com/opencv/opencv/blob/master/modules/dnn/src/dnn.cpp#L1181). I believe you'll have a better support for this case opening a issue on opencv/opencv https://github.com/opencv/opencv
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hybridgroup/gocv/issues/814#issuecomment-806039635, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE73ZBJA5FXWUJ6QQVDX7SLTFISBDANCNFSM4ZQSYE4A .
Hi First really big thanks for you I learn a lot from your profile :) I have Ubuntu server with gpu cuda cudnn enabled and successfully configured and tested I want to use openvino but also with cuda my server have only NVIDIA gpu i dont't have any intel gpu and it will be difficult to have intel gpu because that's a dedicated server
my question in my case can I still used openvino with NVIDIA cuda without intel GPU in opencv? I hope if anyone can answer my quastion because I will be crazy I am trying doing that from one month but I am failed :(((
when i install gocv with cuda it is success and i have successfully gocv with opencv cuda enabled but when I install all to have openvino together with cuda I have the cuda success and also openvino but when I activate the opencv of openvino verstion by go cv openvino env environment file I lost the cuda :( and even the openvino the ie import failed last point I see in make file dldt but that's change to openvino so I am confused about this point also Thank you
Description
Steps to Reproduce
1. 2. 3. 4.
Your Environment
env.sh
orenv.cmd
script before trying togo run
orgo build
?