Its probably your main thermostat but... worth a try to look into EGR cooler thermostat first since it also fails and its so much easier and cheaper to change.
Part #8 on here:
RealOEM.com - Online BMW Parts Catalog
https://www.youtube.com/watch?v=ZhtfKliAkiU