The observed stellar initial mass function (IMF) appears to vary, becoming bottom-heavy in the centres of the most massive, metal-rich early-type galaxies. It is still unclear what physical processes might cause this IMF variation. In this paper, we demonstrate that the abundance of deuterium in the birth clouds of forming stars may be important in setting the IMF. We use models of disc accretion onto low-mass protostars to show that those forming from deuterium-poor gas are expected to have zero-age main sequence masses significantly lower than those forming from primordial (high deuterium fraction) material. This deuterium abundance effect depends on stellar mass in our simple models, such that the resulting IMF would become bottom-heavy - as seen in observations. Stellar mass loss is entirely deuterium-free and is important in fuelling star formation across cosmic time. Using the EAGLE simulation we show that stellar mass loss-induced deuterium variations are strongest in the same regions where IMF variations are observed: at the centres of the most massive, metal-rich, passive galaxies. While our analysis cannot prove that the deuterium abundance is the root cause of the observed IMF variation, it sets the stage for future theoretical and observational attempts to study this possibility.