Skip to content

M1 chip causing problems with PyTorch #12

@katdapre

Description

@katdapre

Hi,

I'm on a Mac with an M1 chip and haven't been able to get PyTorch to work with it (including the instructions for this on the seisbench readme).

I can train models using the seisbench notebook 03a to train phasenet successfully by just commenting out the line
model.to_preferred_device(verbose=True)
and this makes everything run slowly but smoothly.

If I don't comment it out, it shows
Model device: mps:0
and later on when I run the training cell that iterates through epochs, it will cause the error:
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead.
which I think implies that PyTorch has identified the GPU but the float64 format just isn't compatible with it (this is a known M1 issue, e.g. this apple dev issue)

However this means that when running train.py here, I get the same error, and I can't stop it from trying to use GPU because it's identified that MPS is available but then the float64 data isn't compatible.

I fully understand and respect that Apple's hardware is not your problem! I am just wondering if there's any way of turning off the move to GPU (like commenting out that line in the notebook) while running the full training workflow as found in this repository? Perhaps something I can pass to trainer.fit?

Alternatively, I know the notebook03a has that line in augmentations
sbg.ChangeDtype(np.float32), # as expected by the pytorch model
and I'm wondering if there's somewhere else I should be doing this (either in the notebook, or in the train.py workflow) to avoid the error.

If I do manage to get this to work I will definitely be documenting it to help out other M1 users, because it's causing me a world of pain!

Thanks very much,
Kat

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions