The virial theorem for a system of interacting electrons in a crystal, which is described within the framework of the tight-binding model, is derived. We show that, in particular case of interacting massless electrons in graphene and other Dirac materials, the conventional virial theorem is violated. Starting from the tight-binding model, we derive the generalized virial theorem for Dirac electron systems, which contains an additional term associated with a momentum cutoff at the bottom of the energy band. Additionally, we derive the generalized virial theorem within the Dirac model using the minimization of the variational energy. The obtained theorem is illustrated by many-body calculations of the ground state energy of an electron gas in graphene carried out in Hartree-Fock and self-consistent random-phase approximations. Experimental verification of the theorem in the case of graphene is discussed.