I'll do the version where the people are labelled 1, 2, 3, ... and everybody knows which position they are in. Generalising to other cases is still an interesting problem. I repeat my warning that if you're a mathematics student you should resist the temptation to read the answer.
Define an equivalence relation on the set of hat colourings by saying that two colourings are equivalent if they differ in only finitely many places. Choose a representative R(E) for each equivalence class E. Everyone can see all but finitely many hats, so can determine which equivalence class E they are in. Have everybody guess the colour their hat would be in the colouring R(E). The actual colouring is equivalent to R(E), so only finitely many people will guess wrong.
For those who aren't familiar with them, equivalence relations aren't scary at all. They're just a convenient way to describe breaking a set into pieces: two objects are in the same piece if and only if they are equivalent.
The possible generalisations are to the cases where people don't know which number they are, and where the places are indexed by Z instead of N (people can still only see in the "positive" direction). I'm not claiming that all of these are doable.