<ol dir="auto">
<li>I rebuild the opencv and</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="NVIDIA CUDA:                   YES (ver 10.0, CUFFT CUBLAS)
NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
NVIDIA PTX archs:
cuDNN: YES (ver 7.6.4)"><pre class="notranslate"><code class="notranslate">NVIDIA CUDA:                   YES (ver 10.0, CUFFT CUBLAS)
NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
NVIDIA PTX archs:
cuDNN: YES (ver 7.6.4)
</code></pre></div>
<ol start="2" dir="auto">
<li>
<p dir="auto">my config:NVIDIA GeForce MX150 CUDA:10.1 CUDNN：8.0.2</p>
</li>
<li>
<p dir="auto">the darknet can use gpu</p>
</li>
<li>
<p dir="auto">my code is :</p>
</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="auto net = cv::dnn::readNetFromDarknet(&quot;D://yolov4.cfg&quot;, &quot;D://yolov4_last.weights&quot;);
net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
auto output_names = net.getUnconnectedOutLayersNames();

cv::Mat frame, blob;
std::vector&lt;cv::Mat&gt; detections;
frame = imread(&quot;D:/1.jpg&quot;);
auto total_start = std::chrono::steady_clock::now();
cv::dnn::blobFromImage(frame, blob, 1 / 255.0, cv::Size(416, 416));
net.setInput(blob);
auto dnn_start = std::chrono::steady_clock::now();
net.forward(detections, output_names);
auto dnn_end = std::chrono::steady_clock::now();"><pre class="notranslate"><code class="notranslate">auto net = cv::dnn::readNetFromDarknet("D://yolov4.cfg", "D://yolov4_last.weights");
net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);
auto output_names = net.getUnconnectedOutLayersNames();

cv::Mat frame, blob;
std::vector&lt;cv::Mat&gt; detections;
frame = imread("D:/1.jpg");
auto total_start = std::chrono::steady_clock::now();
cv::dnn::blobFromImage(frame, blob, 1 / 255.0, cv::Size(416, 416));
net.setInput(blob);
auto dnn_start = std::chrono::steady_clock::now();
net.forward(detections, output_names);
auto dnn_end = std::chrono::steady_clock::now();
</code></pre></div>
<ol start="5" dir="auto">
<li>If i only use cpu,the time is 1.5 s . if i use the gpu ,the time is 5 s. i do not know why</li>
</ol>
<p dir="auto">hope giving me some tips . thank you</p>
<p dir="auto">1,i rebuild the opencv and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="NVIDIA CUDA:                   YES (ver 10.0, CUFFT CUBLAS)
NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
NVIDIA PTX archs:"><pre class="notranslate"><code class="notranslate">NVIDIA CUDA:                   YES (ver 10.0, CUFFT CUBLAS)
NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
NVIDIA PTX archs:
</code></pre></div>
<p dir="auto">cuDNN:                         YES (ver 7.6.4)</p>
<p dir="auto">2，my  config:NVIDIA  GeForce MX150  CUDA:10.1  CUDNN：8.0.2</p>
<p dir="auto">3，the darknet can use gpu</p>
<p dir="auto">4.my code  is :<br>
auto net = cv::dnn::readNetFromDarknet("D://yolov4.cfg", "D://yolov4_last.weights");<br>
net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);<br>
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA);<br>
auto output_names = net.getUnconnectedOutLayersNames();</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cv::Mat frame, blob;
std::vector&lt;cv::Mat&gt; detections;
frame = imread(&quot;D:/1.jpg&quot;);
auto total_start = std::chrono::steady_clock::now();
cv::dnn::blobFromImage(frame, blob, 1 / 255.0, cv::Size(416, 416));
net.setInput(blob);
auto dnn_start = std::chrono::steady_clock::now();
net.forward(detections, output_names);
auto dnn_end = std::chrono::steady_clock::now();"><pre class="notranslate"><code class="notranslate">cv::Mat frame, blob;
std::vector&lt;cv::Mat&gt; detections;
frame = imread("D:/1.jpg");
auto total_start = std::chrono::steady_clock::now();
cv::dnn::blobFromImage(frame, blob, 1 / 255.0, cv::Size(416, 416));
net.setInput(blob);
auto dnn_start = std::chrono::steady_clock::now();
net.forward(detections, output_names);
auto dnn_end = std::chrono::steady_clock::now();
</code></pre></div>
<p dir="auto">5,if i only use cpu,the time is 1.5 s . if i use the gpu ,the time is 5 s. i do not know why</p>
<p dir="auto">hope giving me some tips . thank you</p>