Tramac / Fast-SCNN-pytorch

A PyTorch Implementation of Fast-SCNN: Fast Semantic Segmentation Network
Apache License 2.0
381 stars 93 forks source link

RuntimeError: CUDA out of memory when run `eval.py` #47

Closed yanzhou-li closed 3 years ago

yanzhou-li commented 3 years ago

@Tramac .When I run eval.py to predict my own images.I met a problem.The code can inference the first image in the folder of validation ,but when I inference the second image and then an error occurred,as fellow: Traceback (most recent call last): File "eval.py", line 96, in <module> evaluator.eval() File "eval.py", line 66, in eval outputs = self.model(image) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/liyanzhou/pycharm_project/demo/Fast-SCNN-pytorch-master/models/fast_scnn.py", line 35, in forward higher_res_features = self.learning_to_downsample(x) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/liyanzhou/pycharm_project/demo/Fast-SCNN-pytorch-master/models/fast_scnn.py", line 159, in forward x = self.dsconv1(x) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/liyanzhou/pycharm_project/demo/Fast-SCNN-pytorch-master/models/fast_scnn.py", line 79, in forward return self.conv(x) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 83, in forward exponential_average_factor, self.eps) File "/home/liyanzhou/anaconda3/envs/py36torch10_fastscnn/lib/python3.6/site-packages/torch/nn/functional.py", line 1697, in batch_norm training, momentum, eps, torch.backends.cudnn.enabled RuntimeError: CUDA out of memory. Tried to allocate 152.00 MiB (GPU 0; 10.76 GiB total capacity; 9.88 GiB already allocated; 36.19 MiB free; 68.67 MiB cached) The size of the image I entered was w*h=5440*3648,the crop-size is 2816.How to solve it? Can you give me some advice? Thank you!

Tramac commented 3 years ago

Hi, I think it’s because the input image size is too large to OOM, maybe you can try to split the image first.

yanzhou-li commented 3 years ago

Hi, I think it’s because the input image size is too large to OOM, maybe you can try to split the image first.

thank you.I reduced the size of the input images.it works.