In this paper, effect of a magnetic field on natural convection flow in a nanofluid-filled enclosure with a linearly heated wall has been analyzed with a new attitude to Lattice Boltzmann method. The cavity is filled with water and nanoparticles of Cu in the presence of the magnetic field. This study has been carried out for the pertinent parameters in the following ranges: the Rayleigh number of base fluid, Ra = 103-105, the volumetric fraction of nanoparticles between 0 and 15 % with interval 5 %. The Hartmann number varied from Ha = 0 to 90 with interval 30, while magnetic field is considered at the direction of the cavity horizontal. Results show that the heat transfer decreases by increment of Hartmann number for various Rayleigh numbers. Heat transfer increases with growth of the volume fractions, but this growth is various for different Rayleigh numbers. The magnetic field augments the effect of nanoparticles at high Rayleigh numbers (Ra = 105), while the effect declines in the presence of the magnetic field for low Rayleigh numbers (Ra = 103 and 104).