thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

How to reduce memory usage? #1143

Open Totemi1324 opened 4 years ago

Totemi1324 commented 4 years ago

Hello there,

I have a problem to face when I try to use the network on my Jetson Nano with a Tegra X1 GPU. The process simply gets "Killed", probably due to over-consumption of memory. I heard that the network requires 2.3GB RAM or so, but the most my GPU can squeeze out is 1.5GB. Here's my Python code:

from darkflow.net.build import TFNet
import cv2
import tensorflow as tf

config = tf.ConfigProto(log_device_placement = False)
config.gpu_options.allow_growth = True
config.gpu_options.per_process_gpu_memory_fraction = 0.4

with tf.Session(config = config) as sess:
    options = {'model': './cfg/yolo.cfg', 'load': './yolov2.weights', 'threshold': 0.3, 'gpu': 1.0}
    tfnet = TFNet(options)

Does anyone know how to reduce the network's memory consumption? If this helps, the only things I want to detect are cars and people.

Thanks for the answers in advance!