ProGamerGov / neural-style-pt

PyTorch implementation of neural style transfer algorithm
MIT License
833 stars 178 forks source link

Error, But Only When Certain Image Combos Are Used #72

Open spot92 opened 4 years ago

spot92 commented 4 years ago

I get the following error, but only when using specific image combinations. I can use the content with other styles or style with other content. Very confusing.

Traceback (most recent call last): File "D:\Neural Style Python\style_transfer_GUI.py", line 513, in main() File "D:\Neural Style Python\style_transfer_GUI.py", line 306, in main optimizer.step(feval) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\optim\lbfgs.py", line 307, in step orig_loss = closure() File "D:\Neural Style Python\style_transfer_GUI.py", line 286, in feval net(img) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 541, in call result = self.forward(*input, *kwargs) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\container.py", line 92, in forward input = module(input) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 541, in call result = self.forward(input, **kwargs) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\conv.py", line 345, in forward return self.conv2d_forward(input, self.weight) File "C:\Users\levic\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\conv.py", line 342, in conv2d_forward self.padding, self.dilation, self.groups) RuntimeError: CUDA out of memory. Tried to allocate 8.16 GiB (GPU 0; 11.00 GiB total capacity; 439.38 MiB already allocated; 8.16 GiB free; 126.62 MiB cached)

ProGamerGov commented 4 years ago

@spot92 I need more information to know if it's a neural-style-pt issue or a PyTorch/CUDA issue. If it's a PyTorch issue with the latest update, then trying to to simplify the code for reproducing the error will help their devs solve it.

Also, do any of the fixes in these issues solve things?

https://github.com/pytorch/pytorch/issues/16417

https://discuss.pytorch.org/t/runtimeerror-cuda-out-of-memory-tried-to-allocate-1-12-mib-gpu-0-11-91-gib-total-capacity-5-52-gib-already-allocated-2-06-mib-free-184-00-kib-cached/42080/9

https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/discussion/91081

spot92 commented 4 years ago

I'll look into them. I just thought it was weird that it only did it with specific combinations of images. Thanks!

sawtl commented 3 years ago

Looks like the Geforce limitation on the usable memory, about 70% of VRAM in Linux with Pytorch (1 GPU). Image max size depends on the framework and option, try to reduce it.