lucidrains / big-sleep

A simple command line tool for text to image generation, using OpenAI's CLIP and a BigGAN. Technique was originally created by https://twitter.com/advadnoun
MIT License
2.57k stars 304 forks source link

dream.reset() = RuntimeError: Tensor for 'out' is on CPU... but expected them to be on GPU #32

Closed nerdyrodent closed 3 years ago

nerdyrodent commented 3 years ago

Hi,

If I try to call dream.reset() I get the following error:

Traceback (most recent call last): File "testme.py", line 21, in dream() File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, kwargs) File "/home/nerdy/github/big-sleep/big_sleep/big_sleep.py", line 341, in forward self.model(self.encoded_text) # one warmup step due to issue with CLIP and CUDA File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, *kwargs) File "/home/nerdy/github/big-sleep/big_sleep/big_sleep.py", line 173, in forward out = self.model() File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, kwargs) File "/home/nerdy/github/big-sleep/big_sleep/big_sleep.py", line 136, in forward out = self.biggan(self.latents(), 1) File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, *kwargs) File "/home/nerdy/github/big-sleep/big_sleep/biggan.py", line 574, in forward embed = self.embeddings(class_label) File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(input, **kwargs) File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 93, in forward return F.linear(input, self.weight, self.bias) File "/home/nerdy/anaconda3/envs/big-sleep/lib/python3.7/site-packages/torch/nn/functional.py", line 1692, in linear output = input.matmul(weight.t()) RuntimeError: Tensor for 'out' is on CPU, Tensor for argument #1 'self' is on CPU, but expected them to be on GPU (while checking arguments for addmm)

My file looks like this:

dream.set_text("A photo of a photo")
dream()
dream.reset()
dream.set_text("A picture of a photo")
dream()
lucidrains commented 3 years ago

Thanks for reporting this! Do you want to give the latest version a try?

nerdyrodent commented 3 years ago

Yup, that works! Many thanks :)