Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing device parameter when initialising optimiser in FishLeg/examples/1_train_autoencoder_with_FishLeg.ipynb #42

Open
Jools-Clarke opened this issue Apr 4, 2024 · 0 comments

Comments

@Jools-Clarke
Copy link
Contributor

## Initialising FishLeg ##
opt = FishLeg(
    model_FishLeg,
    aux_loader,
    likelihood,
    lr=lr,
    beta=beta,
    weight_decay=weight_decay,
    aux_lr=aux_lr,
    aux_betas=(0.9, 0.999),
    aux_eps=aux_eps,
    damping=damping,
    update_aux_every=update_aux_every,
    writer=writer,
    method="antithetic",
    method_kwargs={"eps": 1e-4},
    precondition_aux=True,
    aux_log=True
)

needs to include

device=device

so it becomes

## Initialising FishLeg ##
opt = FishLeg(
    model_FishLeg,
    aux_loader,
    likelihood,
    lr=lr,
    beta=beta,
    weight_decay=weight_decay,
    aux_lr=aux_lr,
    aux_betas=(0.9, 0.999),
    aux_eps=aux_eps,
    damping=damping,
    update_aux_every=update_aux_every,
    writer=writer,
    method="antithetic",
    method_kwargs={"eps": 1e-4},
    precondition_aux=True,
    aux_log=True,
    device=device
)

because the default for FishLeg.__init__() is to use the cpu, but when using mps or cuda (as is supported in the tutorial) this does not function because the tensors end up on seperate devices resulting in this error

Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

or alternatively

Expected all tensors to be on the same device, but found at least two devices, mps and cpu!

this fix has been tested on cuda and cpu, i would appreciate someone checking this on mps

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

No branches or pull requests

1 participant