In this paper, we consider a concentration grating of magnetic nanoparticles optically induced by thermodiffusion in a layer of ferrofluid in the presence of the external homogeneous magnetic field. The applied field is directed along the concentration gradient and leads to the appearance of the internal nonhomogeneous demagnetizing fields. When the system reaches equilibrium, the optical pumping is switched off, and the grating is allowed to relax. We carry out a stability analysis using the Galerkin approach and numerical simulations of the full system of equations to determine the growth rates and the mode amplitudes of the hydrodynamic and concentration perturbations during the relaxation stage.