sound-rnn icon indicating copy to clipboard operation
sound-rnn copied to clipboard

Generating samples from GPU-trained model

Open quantumdude836 opened this issue 8 years ago • 5 comments

After running the sine example described in the README with -gpu_id 0 (so running with CUDA), attempts to generate samples with that model generates the error unknown Torch class <torch.CudaTensor>.

I tried adding require 'cunn' and require 'cutorch' to sample.lua, but that generates another error about invalid arguments to addmm.

Running Arch Linux 4.9.11-1 on x64 laptop. GPU is GTX 1060.

quantumdude836 avatar Mar 01 '17 05:03 quantumdude836

I should also note that I did not test with CPU-trained model because it runs significantly slower (about 2 seconds per 100 iterations on GPU vs 90 seconds on CPU).

quantumdude836 avatar Mar 01 '17 05:03 quantumdude836

Update: the issue is due to type-mismatches. CUDA tensors use float by default, whereas the normal torch tensor uses double. I hacked together a little python script to convert the model data to use torch.DoubleTensor instead of torch.CudaTensor, and the regeneration now works.

Perhaps the eventual solution is to add GPU support to sample.lua.

quantumdude836 avatar Mar 01 '17 18:03 quantumdude836

@quantumdude836: thanks for the update, hopefully a good pointer for anyone else who runs into this. I haven't looked at this project for a while, but PRs welcome if you get around to it :)

johnglover avatar Mar 02 '17 19:03 johnglover

@quantumdude836 any chance of sharing your Python script or a pull request? :-)

mz2 avatar May 12 '17 12:05 mz2

I've uploaded the scripts at https://github.com/quantumdude836/sound-rnn-fixup

quantumdude836 avatar May 12 '17 17:05 quantumdude836