We compute the large-scale limit of the free energy associated with the problem of inference of a finite-rank matrix. The method follows the principle put forward in Mourrat (2018) which consists in identifying a suitable Hamilton.Jacobi equation satisfied by the limit free energy. We simplify the approach of Mourrat (2018) using a notion of weak solution of the Hamilton.Jacobi equation which is more convenient to work with and is applicable whenever the nonlinearity in the equation is convex.