We studied cavitation of nitrogen and argon at their boiling temperatures in spherical pores, modeling the desorption process in cage-like mesoporous materials like FDU-1 and SBA-16. Cavitation of the metastable adsorbate in cage-like pores causes a sharp step on the desorption isotherm near the closure point of the adsorption hysteresis loop. We employed grand canonical Monte Carlo (GCMC) and gauge cell Monte Carlo methods. The GCMC scheme mimics the experimental conditions of cavitation as a spontaneous process. The gauge cell method was designed to simulate the metastable and labile states, not observable in experiments and to trace the nucleation process. The systems modeled were spherical silica pores, ranging from 5 to 10 nm in diameter. We show that the position of cavitation depends on the free energy barrier of formation of the critical nucleus. We achieved an excellent agreement between the simulated and experimental data on nitrogen and argon adsorption-desorption isotherms showing the cavitation phenomenon. Our results suggest that cavitation in nanopores occurs, when the nucleation barrier is reduced to 40-50 kT, regardless of the pore size. This conclusion implies that there is a limit to the influence of the confinement on the onset of cavitation, and thus, cavitation in wide nanopores may be employed to model cavitation in macroscopic systems.