Computing Within Limits: An Empirical Study of Energy Consumption in ML Training and Inference