Finite temperature calculations, based on ab initio molecular dynamics (AIMD) simulations, are a powerful tool able to predict material properties that cannot be deduced from ground state calculations. However, the high computational cost of AIMD limits its applicability for large or complex systems. To circumvent this limitation we introduce a new method named Machine Learning Assisted Canonical Sampling (MLACS), which accelerates the sampling of the Born--Oppenheimer potential surface in the canonical ensemble. Based on a self-consistent variational procedure, the method iteratively trains a Machine Learning Interatomic Potential to generate configurations that approximate the canonical distribution of positions associated with the ab initio potential energy. By proving the reliability of the method on anharmonic systems, we show that the method is able to reproduce the results of AIMD with an ab initio accuracy at a fraction of its computational cost.