Skip to content

Unconditional image generation with accelerate and train_unconditional.py crashes with MPS but works on CPU #6568

Answered by nickyreinert
nickyreinert asked this question in Q&A
Discussion options

You must be logged in to vote

If you check the error stack, you see it comes from utils/torch_utils.py > def randn_tensor and this line

latents = torch.randn(shape, generator=generator, device=rand_device, dtype=dtype, layout=layout).to(device)

Debugging shows, that device enters the function as "cpu", which is indeed wrong.

The following line in pipelines/ddpm/pipeline_ddpm.pycalls the randn_tensor:

image = randn_tensor(image_shape, generator=generator)

With the following comment:

# randn does not work reproducibly on mps

Hm, well. When I pass the device in the function call, it works:

image = randn_tensor(image_shape, generator=generator, device=self.device)

Long story short: Setting the desired argument works.

I …

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nickyreinert
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nickyreinert
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants