Darkflow: Darkflow is not using my GPU

Created on 13 Oct 2017  Â·  12Comments  Â·  Source: thtrieu/darkflow

Sorry for this basic question, but I'm a newcomer to darkflow.
Following "Using darkflow from another python application", in readme.md.
I can not get it to run on GPU, "Running entirely on CPU" appears in the console.
Later each image takes a little more than a second to be processed without use GPU.
Other Cnn with Tensorflow, use the GPU without problems on the same computer.
Any idea where my problem may be, to make darkflow use the GPU?
Windows 10, nvidia gtx 1070.

Most helpful comment

After debugging I was able to check that I had an error in the options dict.
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1, "GPU": 1.0}
Instead of "GPU": 1.0, it should be "gpu": 1.0
Now it works using the GPU.

All 12 comments

Would you share the command line you used to run darkflow?
On Fri, Oct 13, 2017 at 8:07 PM clitenmestra notifications@github.com
wrote:

Sorry for this basic question, but I'm a newcomer to darkflow.
Following "Using darkflow from another python application", in readme.md.
I can not get it to run on GPU, "Running entirely on CPU" appears in the
console.
Later each image takes a little more than a second to be processed without
use GPU.
Other Cnn with Tensorflow, use the GPU without problems on the same
computer.
Any idea where my problem may be, to make darkflow use the GPU?
Windows 10, nvidia gtx 1070.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/thtrieu/darkflow/issues/417, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABUpdI48dAhM3Qfwsu8CiBh-5SanzEWxks5sr0RigaJpZM4P4VEa
.

Thanks rlan. As you can see I am absolutely lost. Perhaps the documentation, for a novice, is somewhat scarce.
I try to run a script very similar to the one described in the section:

Using darkflow from another python application

as you can see I have tried two different options although the result is the same.
Whether I run the script in console or in IDE, Spyder, I get the same result.
The console command is: _python prudemo01.py_ without args
The code:

# -*- coding: utf-8 -*-
"""
Created on Tue Oct 10 12:20:09 2017

"""
from darkflow.net.build import TFNet
import cv2
import time
import os

#options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1, "GPU": 1.0}

tfnet = TFNet(options)

base="f:/escocia/test/"
l=[]
cont=0
li=os.listdir(base)
for imagen in li:   
    imgcv = cv2.imread(base+imagen)
    t = time.process_time()
    result = tfnet.return_predict(imgcv)
    elapsed_time = time.process_time() - t
    l.append([elapsed_time,result])
    cont=cont+1
    if (cont%50==0):
        print (cont)

print ("Script ended wit ",len(l)," images")

The output:

(tensorflow) F:\tut-tf\darkflow\darkflow>python prudemo01.py
Parsing ./cfg/yolo.cfg
Parsing cfg/yolo.cfg
Loading bin/yolo.weights ...
Successfully identified 203934260 bytes
Finished in 0.02052593231201172s
Model has a coco model name, loading coco labels.

Building net ...
Source | Train? | Layer description                | Output size
-------+--------+----------------------------------+---------------
       |        | input                            | (?, 608, 608, 3)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 608, 608, 32)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 304, 304, 32)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 304, 304, 64)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 152, 152, 64)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 152, 152, 128)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 152, 152, 64)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 152, 152, 128)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 76, 76, 128)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 76, 76, 256)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 76, 76, 128)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 76, 76, 256)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 38, 38, 256)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 38, 38, 512)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 38, 38, 256)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 38, 38, 512)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 38, 38, 256)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 38, 38, 512)
 Load  |  Yep!  | maxp 2x2p0_2                     | (?, 19, 19, 512)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 19, 19, 512)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 19, 19, 512)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | concat [16]                      | (?, 38, 38, 512)
 Load  |  Yep!  | conv 1x1p0_1  +bnorm  leaky      | (?, 38, 38, 64)
 Load  |  Yep!  | local flatten 2x2                | (?, 19, 19, 256)
 Load  |  Yep!  | concat [27, 24]                  | (?, 19, 19, 1280)
 Load  |  Yep!  | conv 3x3p1_1  +bnorm  leaky      | (?, 19, 19, 1024)
 Load  |  Yep!  | conv 1x1p0_1    linear           | (?, 19, 19, 425)
-------+--------+----------------------------------+---------------
Running entirely on CPU
2017-10-14 09:19:08.767220: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-10-14 09:19:08.767261: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-14 09:19:09.032528: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 1070
major: 6 minor: 1 memoryClockRate (GHz) 1.7465
pciBusID 0000:01:00.0
Total memory: 8.00GiB
Free memory: 6.66GiB
2017-10-14 09:19:09.032601: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 0
2017-10-14 09:19:09.033434: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0:   Y
2017-10-14 09:19:09.033844: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0)
Finished in 5.53765082359314s

50
100
150
200
Script ended wit  240  images

@clitenmestra I haven't tried calling darkflow from a python program. I run it from command line. However, your options includes "gpu" option so that seems ok. You seem to be running in a python virtual environment. Have you verified that tensorflow is indeed using GPU? In case you don't know, GPU install is different from CPU install: https://www.tensorflow.org/install/install_windows. I would also verify GPU is being used by running: https://www.tensorflow.org/tutorials/using_gpu

Yes, Tensorflow was installed in my equipe as gpu mode and I run another cnn with tensorflow using the gpu.

@clitenmestra I see. From your log above, I see "Creating TensorFlow device (/gpu:0)". Seems to suggest that GPU is being used. Did you watch the GPU utilization? In my experience, it goes up and down (zero). Zero is probably OpenCV as I think it is not GPU accelerated, at least not so in my environment.

I was monitoring, using the _nvidia-smi_ utility, the use of GPU with 0 results of use in the Darkflow example previously put.
Of course! running other networks with tensorflow showed the intensive use of the GPU.

After debugging I was able to check that I had an error in the options dict.
options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1, "GPU": 1.0}
Instead of "GPU": 1.0, it should be "gpu": 1.0
Now it works using the GPU.

@clitenmestra you please post the out put of the script after pointing to GPU - Is there any change in the output text , or the execution time ?

Finished in 5.53765082359314s

Does that time change ?

Use 'gpu' : 0.5 instead of 'GPU' : 1.0 . You can edit the 0.5 later to 0.75 or 0.85.
This the amount of GPU usage space you are giving to run the program .

@clitenmestra Can you tell me how to get a predicted picture? I can only do the output of the json file, but I want to get the predicted result graph by running the py file directly (that is, the same effect as the cmd run), your help is very important to me, thank you!

image

Using GTX 1050, I have Cuda 10.1, TensorFlow GPU 1.15 installation, while training I had set --GPU 1.0
But as per the log, while training only CPU is being used.

You need to install cuda 10 not 10.1

On Fri, 8 Nov 2019, 10:30 am Devika Bihani, notifications@github.com
wrote:

[image: image]
https://user-images.githubusercontent.com/41909437/68461194-aa2cc280-022f-11ea-8d51-66fa60c8d6ed.png

Using GTX 1050, I have Cuda 10.1, TensorFlow GPU 1.15 installation, while
training I had set --GPU 1.0
But as per the log, while training only CPU is being used.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/thtrieu/darkflow/issues/417?email_source=notifications&email_token=AL6S274RTBHVAS26QGXY2TTQSUPTTA5CNFSM4D7BKENKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDPDRPQ#issuecomment-551434430,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AL6S2753KIKCTWEXVTV6TKLQSUPTTANCNFSM4D7BKENA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bareblackfoot picture bareblackfoot  Â·  4Comments

hrshovon picture hrshovon  Â·  5Comments

ManojPabani picture ManojPabani  Â·  4Comments

wonny2001 picture wonny2001  Â·  4Comments

humanova picture humanova  Â·  4Comments