FaceDetection-DSFD icon indicating copy to clipboard operation
FaceDetection-DSFD copied to clipboard

Is it possible to use smaller GPU for inference?

Open AmitRozner opened this issue 5 years ago • 10 comments

I read about you training 8 images in a batch on P40. Is it possible to use the code with GTX 1080TI (12GB) with smaller batch size?

AmitRozner avatar Mar 20 '19 12:03 AmitRozner

Hi @AmitRozner Of course. But Training with smaller batch size may reduce detection performance slightly.

swordlidev avatar Mar 21 '19 06:03 swordlidev

My gpu is V100, 16G, when I run python demo.py --trained_model weights/WIDERFace_DSFD_RES152.pth --img_root data/worlds-largest-selfie.jpg It gets error: RuntimeError: CUDA out of memory Is it possible to use smaller GPU?

cqlyiyeshu avatar Apr 06 '19 02:04 cqlyiyeshu

Hi @cqlyiyeshu I think that 16G is enough. you can try to use less scale in demo.py. especially for 2x.

swordlidev avatar Apr 08 '19 09:04 swordlidev

@lijiannuist My gpu is 8G,how can i solve the error "RuntimeError: CUDA out of memory "? error log is: traceback (most recent call last): File "demo.py", line 248, in test_oneimage() File "demo.py", line 232, in test_oneimage det_b = np.row_stack((det_b, infer(net , img , transform , thresh , cuda , bt))) File "demo.py", line 98, in infer y = net(x) # forward pass File "/usr/lib64/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/home/jy/FaceDetection-DSFD/face_ssd.py", line 235, in forward conv4_3_x = self.layer2(conv3_3_x) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/container.py", line 91, in forward input = module(input) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/container.py", line 91, in forward input = module(input) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/usr/lib/python2.7/site-packages/torchvision/models/resnet.py", line 85, in forward out = self.bn3(out) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/usr/lib64/python2.7/site-packages/torch/nn/modules/batchnorm.py", line 66, in forward exponential_average_factor, self.eps) File "/usr/lib64/python2.7/site-packages/torch/nn/functional.py", line 1254, in batch_norm training, momentum, eps, torch.backends.cudnn.enabled RuntimeError: CUDA error: out of memory

jiangziya avatar Apr 11 '19 02:04 jiangziya

Hi @cqlyiyeshu I think that 16G is enough. you can try to use less scale in demo.py. especially for 2x.

@lijiannuist Do you mean resizing the input image to a smaller size?

JaywongWang avatar Apr 11 '19 05:04 JaywongWang

Hi @cqlyiyeshu I think that 16G is enough. you can try to use less scale in demo.py. especially for 2x.

@lijiannuist Do you mean resizing the input image to a smaller size?

yes,i resize as 100x100

jiangziya avatar Apr 11 '19 06:04 jiangziya

Hi, try to add torch.set_grad_enabled(False) inside test_oneimage() function (at the beginning of the function) if your torch version is >= 0.4. It works for me.

yihongXU avatar Apr 24 '19 12:04 yihongXU

You can use this https://github.com/vlad3996/FaceDetection-DSFD with original author's checkpoint or try at least with torch.no_grad(): to inference

vlad3996 avatar Apr 24 '19 20:04 vlad3996

My gpu is V100, 16G, when I run python demo.py --trained_model weights/WIDERFace_DSFD_RES152.pth --img_root data/worlds-largest-selfie.jpg It gets error: RuntimeError: CUDA out of memory Is it possible to use smaller GPU? 应该用的是0.4+的torch吧,内存没有释放,用0.3的torch就没问题了

TekiLi avatar May 14 '19 08:05 TekiLi

My gpu is V100, 16G, when I run python demo.py --trained_model weights/WIDERFace_DSFD_RES152.pth --img_root data/worlds-largest-selfie.jpg It gets error: RuntimeError: CUDA out of memory Is it possible to use smaller GPU? 应该用的是0.4+的torch吧,内存没有释放,用0.3的torch就没问题了

用0.4+的torch确实会报内存不够,请问有什么方法可以释放内存嘛?我现在只能一张图片一张图片地测。

KarelZhang avatar May 23 '19 04:05 KarelZhang