How safe is to drink 2 gallons a water a day while on a low calorie diet?

Water intake. Not really safe. You need roughly 64 ounces of fluid a day. 2 gallons of water is 256 ounces of fluid, not only that, it is free water rather than balanced electrolytes. The net effect will be that you will eventually become hyponatremic and that can cause you all sorts of problems. You could probably do a gallon and still be okay. 2 is pushing it.
Not safe. Consuming excess water can "dilute" your body causing electrolyte imbalances. Electrolytes are important as every cell in our body requires a proper balance of electrolytes. Electrolytes can be replenished in our diet, but eating a low calorie diet puts one at risk for not consuming sufficient electrolytes. Seek your doctor's advise before implementing any diet change.