'Running keras model on ubuntu VM (UTM) on Mac with M1 chip
I have a Mac with an M1 Pro chip. I was able to install keras/tensorflow with tensorflow-metal PluggableDevice. My image classification model runs smoothly on my M1.
Because of some reasons I also need to run code on an Ubuntu VM machine - I used UTM and install ubuntu 20.04 with the UTM guide. In that VM I successfully installed keras/tensorflow.
When I run exactly the same code with exactly the same data as on my M1 inside Ubuntu I don't get any errors but the loss is exploding:
I tried every technique that I know for loss explosion:
- gradient by norm clipping
- smaller learning rate
- normalization of network outputs
- different optimizer
None of the above helped me and on Ubuntu, this model is just not learning. Does anyone properly set Ubuntu on their Mac with M1 that keras can properly run?
Solution 1:[1]
I've been struggling with the same issue and with the same goal for a good half day (nan loss when trying to run code on an Ubuntu VM machine in Mac M1 (UTM + ubuntu 20.04). Code works fine when running outside VM.
I find a magical workaround: in the VM settings, set the number of cores to 1. After this change I didn't get nan values of the loss anymore and training converged.
HTH
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Giovanni Marchiori |