Is gravity a source of infinite energy at a cosmological scale
Gravity travels at light speed (or less, possibly), so even in an infinite non-expanding universe of finite age you'd only be gravitationally interacting with a finite mass in a finite volume. Our universe is observed to be expanding, further inhibiting us from coming into contact with new objects.

Furthermore, a common assumption of cosmological models is that the universe is homogeneous and isotropic on large scales. Meaning it is pretty much identical in all directions. Observations support this assumption. One net effect of this is that the gravitational potential energy you experience from objects outside (roughly) your supercluster is zero (and really close to it from things outside your own galaxy, actually). They just balance each other out.