animegan2-pytorch icon indicating copy to clipboard operation
animegan2-pytorch copied to clipboard

Any low mem cmd option available

Open muruga86 opened this issue 3 years ago • 4 comments

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)

muruga86 avatar Nov 30 '21 18:11 muruga86

Try --device cpu

bryandlee avatar Nov 30 '21 21:11 bryandlee

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

muruga86 avatar Dec 01 '21 00:12 muruga86

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

bryandlee avatar Dec 01 '21 00:12 bryandlee

how to use TensorRT in animegan2-pytorch?

xermao avatar Dec 28 '21 08:12 xermao