diffusion-models-class icon indicating copy to clipboard operation
diffusion-models-class copied to clipboard

Introduction to Diffusers Notebook - Mac M1 Support

Open schauppi opened this issue 3 years ago • 4 comments

I have spotted an Issue not directly for this notebook but for Mac m1 users.

If you set device = torch.device("cpu") the output of show_images(xb).resize((8 * 64, 64), resample=Image.NEAREST) gives you 8 different images of butterflies. Bit if you set device = torch.device("mps") the output of the same functions return 8 times the same butterfly.

Don´t know what's going on under the hood with torch gpu for Mac m1 yet - didn't find something googeling it.

schauppi avatar Nov 29 '22 08:11 schauppi

Very strange! Hopefully someone with a mac can figure out a fix, I can't think what would be causing this.

johnowhitaker avatar Nov 29 '22 09:11 johnowhitaker

I can repo this but I think the issue in pytorch core from this issue I found:

https://github.com/pytorch/pytorch/issues/84523

angellmethod avatar Dec 24 '22 03:12 angellmethod

The simple workaround as far as this notebook goes looks like moving the detach().cpu() operation into make_grid.

grid = torchvision.utils.make_grid(x.detach().cpu()) 

grid_im = grid.permute(1, 2, 0).clip(0, 1) * 255

angellmethod avatar Dec 24 '22 21:12 angellmethod

Thanks for the detective work @angellmethod, I'll test and push the change post Christmas chaos :)

johnowhitaker avatar Dec 25 '22 04:12 johnowhitaker