Carbon emissions from fossil energy not only cause a lot of extreme weathers, but also global warming. Accurately forecasting of electricity demand can promote the development of the renewable energy, which is vital to achieving the goal of carbon peak and carbon neutrality. In this paper, a nonlinear interval grey model based on genetic algorithm and BP neural network optimization (BPGA-IGM (1,1)) is proposed to predict electricity consumption. Firstly, based on the forecast of China's energy consumption and China's coal consumption, the reliability and superiority of the BPGA-IGM (1,1) model have been verified. Then, the model and other competing models are applied to forecast Shanghai's electricity consumption. The empirical results show that the model designed in this paper could obtain more accurate and reliable prediction results. According to the empirical results, Shanghai's electricity consumption continues to rise to a higher level of no less than 1978.19 million kWh by 2025. On the basis of this issue, several suggestions have been offered.