In this paper, we study a nonlocal variational problem which consists of minimizing in $L^2$ the sum of a quadratic data fidelity and a regularization term corresponding to the $L^p$-norm of the nonlocal gradient. In particular, we study convergence of the numerical solution to a discrete version of this nonlocal variational problem to the unique solution of the continuum one. To do so, we derive an error bound and highlight the role of the initial data and the kernel governing the nonlocal interactions. When applied to variational problem on graphs, this error bound allows us to show the consistency of the discretized variational problem as the number of vertices goes to infinity. More precisely, for networks in convergent graph sequences (simple and weighted deterministic dense graphs as well as random inhomogeneous graphs), we prove convergence and provide rate of convergence of solutions for the discrete models to the solution of the continuum problem as the number of vertices grows.