  Magnetic field strengths inferred for relativistic outflows including
gamma-ray bursts (GRB) and active galactic nuclei (AGN) are larger than naively
expected by orders of magnitude. We present three-dimensional relativistic
magnetohydrodynamics (MHD) simulations demonstrating amplification and
saturation of magnetic field by a macroscopic turbulent dynamo triggered by the
Kelvin-Helmholtz shear instability. We find rapid growth of electromagnetic
energy due to the stretching and folding of field lines in the turbulent
velocity field resulting from non-linear development of the instability. Using
conditions relevant for GRB internal shocks and late phases of GRB afterglow,
we obtain amplification of the electromagnetic energy fraction to $\epsilon_B
\sim 5 \times 10^{-3}$. This value decays slowly after the shear is dissipated
and appears to be largely independent of the initial field strength. The
conditions required for operation of the dynamo are the presence of velocity
shear and some seed magnetization both of which are expected to be commonplace.
We also find that the turbulent kinetic energy spectrum for the case studied
obeys Kolmogorov's 5/3 law and that the electromagnetic energy spectrum is
essentially flat with the bulk of the electromagnetic energy at small scales.
