We investigate NLTE effects for magnesium and calcium in the atmospheres of late-type giant and supergiant stars. The aim of this paper is to provide a grid of NLTE/LTE equivalent width ratios W/W* of Mg and Ca lines for the following range of stellar parameters: Teff in [3500,5250]K, log(g) in [0.5,2.0]dex and [Fe/H] in [-4.0,0.5]dex. We use realistic model atoms with the best physics available and taking into account the fine structure. The Mg and Ca lines of interest are in optical and near IR ranges. A special interest concerns the lines in the Gaia spectrograph (RVS) wavelength domain [847,874]nm. The NLTE corrections are provided as function of stellar parameters in an electronic table as well as in a polynomial form for the Gaia/RVS lines.