In order to improve the operating stability of a centrifugal compressor, discrete cavities are introduced just upstream of the impeller and optimized for further improve the operating stability. Aerodynamic analysis is performed using a commercial code, ANSYS-CFX 15.0, to solve three-dimensional Reynolds-averaged Navier–Stokes equations with a shear stress transport turbulence model. The stall margin of the centrifugal compressor is used as the objective function, and three geometric parameters associated with the shape of the discrete cavities (the width and angle of the cavity port, and the axial distance between cavities) were selected as design variables. The Latin hypercube sampling method is used to compose the design space with 27 design points, and a radial basis neural network model is constructed as a surrogate model of the objective function. The optimization results show that the stall margin of the centrifugal compressor with the optimum discrete cavities is improved by 15.4% compared to the compressor without cavity.