Whether it's 4 or 2GB doesn't matter, neither card is going to benefit from having more than 2GB memory anyway.
However, it does matter whether it's GDDR5 or DDR3. GDDR5 is much faster. The 4GB memory on the GT 640 is probably DDR3, while the 2GB memory on the GTX 645 is probably GDDR5, which would make that card significantly faster.