An automatic control algorithm considering the pump interaction for flattening the gain of a fiber Raman amplifier is derived from the Raman scattering equations. A pseudo-inverse gain matrix is introduced to adjust the powers of the pump lasers. The pump-to-pump interaction is compensated by the pump coefficients. It is demonstrated experimentally that the convergence of this algorithm is faster than that of the algorithm without considering the pump-to-pump interaction. In a system with 50-km SMF and 13.4km DCF, flattened Raman gain 15dB with a fluctuation no more than 0.40dB over a 45-nm bandwidth and 26dB with a fluctuation less than 0.8dB are realized in the experiment.