Lesson 2 - troubleshoot macbook m1 issue

Has anyone managed to solve the error (see below) that arises when attempting to use aug_transforms technique on macos m1?

NotImplementedError: The operator 'aten::_linalg_solve_ex.result' is not currently implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.

Update: using chatgpt4 I learned that adding below adjustment helps a little bit:

[instanceOfDataBlock].new(item_tfms=Resize(128), batch_tfms=custom_aug_transforms)

where custom_aug_transforms is

from fastai.vision.augment import *
custom_aug_transforms = [RandomResizedCrop(128, min_scale=0.35), Flip(), Brightness(), Contrast(), Rotate(max_deg=10.0)]

I am not sure impact of custom_aug_transforms is equally good as aug_transforms but seems not too bad. In the meantime please visit github issue to implement aten::_linalg_solve_ex.result operator and vote for it to increase its priority

2 Likes

Here is how I got the code to work:

from fastai.vision.augment import *
custom_aug_transforms = [RandomResizedCrop(128, min_scale=0.35), Flip(), Brightness(), Contrast(), Rotate(max_deg=10.0)]

bears = bears.new(item_tfms=Resize(128), batch_tfms=custom_aug_transforms)
dls = bears.dataloaders(path)
dls.train.show_batch(max_n=8, nrows=2, unique=True)

Don’t forget to change the following cell to:
bears = bears.new(
item_tfms=RandomResizedCrop(224, min_scale=0.5),
batch_tfms=custom_aug_transforms)
dls = bears.dataloaders(path)

I tried this and I still get
TypeError: can’t convert mps:0 device type tensor to numpy. Use Tensor.cpu to copy the tensor to host memory first

Hello!
I’m delighted that the issue has been resolved! Your update with the outcome is greatly appreciated.

Best Regards,
Raymond
choice advantages