Skip to content

Conversation

@hlky
Copy link
Contributor

@hlky hlky commented Dec 20, 2024

What does this PR do?

Torch CUDA Tests (others) has been failing from EMAModel.

FAILED tests/others/test_ema.py::EMAModelTests::test_from_pretrained - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

ema_unet is on the correct device as it's created from unet which is moved to torch_device

unet = UNet2DConditionModel.from_pretrained(self.model_id, subfolder="unet")
unet = unet.to(torch_device)
ema_unet = EMAModel(unet.parameters(), decay=decay, model_cls=UNet2DConditionModel, model_config=unet.config)

loaded_ema_unet is on CPU.

This matches torch.allclose call with original_param, loaded_param and the order of the error cuda:0 and cpu!.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hlky hlky merged commit bf9a641 into huggingface:main Dec 21, 2024
8 checks passed
Foundsheep pushed a commit to Foundsheep/diffusers that referenced this pull request Dec 23, 2024
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants