In order to conduct thermal management of electronic components with nonuniform temperature, the flow and heat transfer characteristics of nanofluids in four kinds of cavities with inclined nonuniform heating surfaces were simulated by the lattice Boltzmann model. Classified from the two-dimensional geometry, the influence of parallelogram cavity, inverted parallelogram cavity, trapezoid cavity, and inverted trapezoid cavity was researched. Considering the complex thermal environment in reality, effects of four kinds of heating wall boundary conditions (constant temperature, gradient temperature, piecewise temperature, and normal temperature) are discussed. Results showed that the flow velocity of nanofluid in the inverted trapezoid cavity is the highest. The highest average Nusselt number near the heating wall of the inverted parallelogram cavity can reach 3.97. Among all kinds of wall heating conditions, cavities with constant temperature have the best heat transfer effect, whose Nu number is 33.4% higher than that of cavities with piecewise temperature in average. The average total entropy change of inverted parallelogram cavity is 16.83. According to the simulation results, the best arrangement of natural convection cooling can be determined.