bryandlee / animegan2-pytorch

PyTorch implementation of AnimeGANv2
MIT License
4.4k stars 639 forks source link

Any low mem cmd option available #36

Open muruga86 opened 2 years ago

muruga86 commented 2 years ago

Hi,

I am trying to run the program on a ubnutu 20.4 machine with GTX1650Ti GPU, but face lack of memory issue. Does this module have any low mem option i.e like reduce channel option with less memory requirement. Or any other work around possible?

python3 test.py --input_dir inputimg --output_dir outputimg --device cuda model loaded: ./weights/paprika.pt Traceback (most recent call last): File "test.py", line 92, in test(args) File "test.py", line 48, in test out = net(image.to(device), args.upsample_align).cpu() File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, kwargs) File "/home/murugan86/anime/animagen-pytorch-mur/animegan2-pytorch/model.py", line 91, in forward out = self.block_a(input) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 117, in forward input = module(input) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 423, in forward return self._conv_forward(input, self.weight) File "/home/murugan86/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 419, in _conv_forward return F.conv2d(input, weight, self.bias, self.stride, RuntimeError: CUDA out of memory. Tried to allocate 7.96 GiB (GPU 0; 3.82 GiB total capacity; 2.07 GiB already allocated; 549.38 MiB free; 2.09 GiB reserved in total by PyTorch)

bryandlee commented 2 years ago

Try --device cpu

muruga86 commented 2 years ago

when trying with cpu option getting output like this

python3 test.py --input_dir inputimg --output_dir outputimg --device cpu model loaded: ./weights/paprika.pt Killed

bryandlee commented 2 years ago

Seems like you don't have enough RAM as well. Here are some possible options you can try:

  1. Use colab
  2. Try TensorRT conversion with FP16
  3. Downsize the image
xermao commented 2 years ago

how to use TensorRT in animegan2-pytorch?