The investigation of entropy generation is highly desirable for the optimization of the thermal systems to avoid larger energy wastage and ensure higher heat transfer rate. The numerical investigation of natural convection within enclosures with the concave and convex horizontal walls involving the Rayleigh–Bénard heating is performed via entropy generation approach. The spatial distributions of the temperature (θ), fluid flow (ψ), entropy generation due to heat transfer and fluid friction (Sθ and Sψ) are discussed extensively for various Rayleigh numbers and Prandtl numbers involving various wall curvatures. A number of complex patterns of spatial distributions of fluid flow and temperature for cavities with concave or convex isothermal walls (top and bottom) have been obtained. The zones of high entropy generation for temperature and fluid flow are detected within cavities with concave and convex horizontal walls. The optimal situation involves the high heat transfer rate with moderate or low entropy generation. Overall, case 3 (highly concave) is found to be optimal over cases 1 and 2 (concave) and cases 1–3 (convex) for all Pr and Ra. © 2017 Taylor & Francis.