Abstract The authors develop the DEM-based procedure for the numerical testing of granular samples under non-uniform compression with different load programs. The algorithm of initial packings of particles is proposed. The calculations are performed for different methods of loading with suppressed dilatancy and with dilatancy-generated volume. The macro characteristics of the stress–strain behavior of the test samples are related with the micro properties of discrete particles. The post-critical shearing induces the unstable behavior with localizations of shears, and a descending branch appears in the load diagram. The application ranges of the developed method for the mathematical modeling of shear localization are defined.