I am trying to use the GPU of my virtual machine with OpenCV library (4.2) and Python 3.7.
I have installed opencv with CUDA and the following command returns 1:
import cv2 count = cv2.cuda.getCudaEnabledDeviceCount() print(count) I tried to run my code with and without leveraging GPU:
start = time.time() network = cv.dnn.readNetFromDarknet(config_path, weights_path) if IS_CUDA: network.setPreferableBackend(cv.dnn.DNN_BACKEND_CUDA) network.setPreferableTarget(cv.dnn.DNN_TARGET_CUDA) my_function(network, frame) end = time.time() print(end - start) But the running time is the same.
My question: Is using setPreferableBackend() and setPreferableTarget() enough to leverage GPU power ?
https://stackoverflow.com/questions/66694609/leveraging-gpu-with-opencv-4-2 March 18, 2021 at 11:56PM
没有评论:
发表评论