Help with M1 error: Adaptive pool MPS: input sizes must be divisible by output sizes

Hello guys!
I am on Notebook 5 “Pet Breeds” and I am facing this error:
Adaptive pool MPS: input sizes must be divisible by output sizes

The line that seemingly gives me the error is x1 = x1.affine_coord(sz=224) and it is linked with this line of code return torch._C._nn.adaptive_avg_pool2d(input, _output_size)

I believe it is due to my Macbook chip M1… I tried to solve it by setting torch.device("mps") but didn’t work. I don’t know what else to try. Does anyone have a solution that isn’t to switch to Paperspace? Their free machines are occupied most of the time I try to use them.

Thank you in advance,
Kev

Hello,

According to this comment by a PyTorch maintainer, adaptive average pooling with an MPS backend is not currently supported when the input size is not divisible by the output size, so the error you have encountered is to be expected. Furthermore, it appears that enabling CPU fallback via setting the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1, which is necessary to perform operations that are not yet implemented for MPS, does not resolve the problem, although you should give it a try yourself nonetheless. Therefore, I reckon your options would be I) Ensuring input dimensions are a factor of output dimensions whenever conducting adaptive pooling, but this is not a long-term solution, or II) Using Colab or Kaggle Notebooks. They provide free GPUs and TPUs up to a certain limit, and I’ve found both services to be generally more reliable than Paperspace.

2 Likes