I didn't replace the relays myself, but sent the module off to a guy who did the dirty work for me. He must have done a good job as this was several years ago and not had any problems with the central locking since.
The gm5 module is located behind the glove box. You'll need to remove that to get to the module. A Google search or perhaps a search on the e46fanatics forums should lead you to detailed instructions with pictures on how to remove the gm5.
I generally advise that problematic gm5's are repaired, as opposed to replaced, to avoid having to do any coding.
Note also that the gm5, in addition to the central locking, also controls other things such as the electric windows and convertible top and for this reason is coded specifically to your vehicle type.
So, for example, if you were to buy one off eBay (not recommended) taken from a saloon with a sunroof you'll probably encounter problems retracting the roof on your vert. You would also probably find that the electric window buttons won't work as you might expect.
To avoid these problems, I recommend that your problematic gm5 be repaired.