msieg / deep-music-visualizer

The Deep Visualizer uses BigGAN (Brock et al., 2018) to visualize music.
389 stars 104 forks source link

errors with gcloud vm in tutorial --resolution 512 #14

Open XanaDublaKublaConch opened 3 years ago

XanaDublaKublaConch commented 3 years ago

I followed the suggestion of the README and tried this out on the recommended gcloud VM, but I can't get a 512 size to generate. Is there a workaround (multiple GPUs?) I'm not familiar with pytorch so I don't know if this is a VM sizing issue or a problem with how this project batches data to CUDA memory or something. My audio is a little over 3 minutes.

Traceback (most recent call last):
  File "visualize.py", line 378, in <module>
    output = model(noise_vector, class_vector, truncation)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/pytorch_pretrained_biggan/model.py", line 295, in forward
    z = self.generator(cond_vector, truncation)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/pytorch_pretrained_biggan/model.py", line 239, in forward
    z = layer(z, cond_vector, truncation)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/johnny/viz/venv/lib/python3.7/site-packages/pytorch_pretrained_biggan/model.py", line 198, in forward
    out = x + x0
RuntimeError: CUDA out of memory. Tried to allocate 3.75 GiB (GPU 0; 11.17 GiB total capacity; 8.91 GiB already allocated; 365.44 MiB free; 10.37 GiB reserved in total by PyTorch)
drscotthawley commented 3 years ago

Try decreasing the batch size. From the README:

batch_size

BigGAN generates the images in batches of size [batch_size]. The only reason to reduce batch size from the default of 30 is if you run out of CUDA memory on a GPU. Reducing the batch size will slightly increase overall runtime.

Default: 30

Example:

python visualize.py --song beethoven.mp3 --batch_size 20

In my case, with a RTX 3070 with only 8 GB of VRAM, I needed to decrease the batch size to 10.