Let A be a d-dimensional smooth algebra over a perfect field of characteristic not 2. Let Um(n+1)(A)/En+1 (A) be the set of unimodular rows of length n + 1 up to elementary transformations. If n >= (d + 2)/2, it carries a natural structure of group as discovered by van der Kallen. If n = d >= 3, we show that this group is isomorphic to a cohomology group H-d (A, G(d+1)). This extends a theorem of Morel, who showed that the set Um(d+1)(A)/SLd+1(A) is in bijection with H-d (A, G(d+1))/SLd+1(A). We also extend this theorem to the case d = 2. Using this, we compute the groups Um(d+1)(A)/Ed+1(A) when A is a real algebra with trivial canonical bundle and such that Spec(A) is rational. We then compute the groups Um(d+1)(A)/SLd+1 (A) when d is even, thus obtaining a complete description of stably free modules of rank d on these algebras. We also deduce from our computations that there are no stably free non free modules of top rank over the algebraic real spheres of dimension 3 and 7.