The nonlocal viscosity kernels of polymer melts have been determined by means of equilibrium molecular dynamics upon cooling toward the glass transition. Previous results for the temperature dependence of the self-diffusion coefficient and the value of the glass transition temperature are confirmed. We find that it is essential to include the attractive part of the interatomic potential in order to observe a strong glass transition. The width of the reciprocal space kernel decreases dramatically near the glass transition, being described by a deltalike function near and below the glass transition, leading to a very broad kernel in physical space. Thus, spatial nonlocality turns out to play an important role in polymeric fluids at temperatures near the glass transition temperature.