As a counter-point to this, to anyone reading who might be discouraged, the research groups I personally know mostly care about sufficient grades (i.e. that you're smart, hard-working, not stupid). The ability to get outstanding grades doesn't correlate that well with research ability; it just correlates well with your ability to do exams.
Given sufficient grades, it's infinitely more important that, say, an addition to your research group is able to work well with the other people in it than what specific grades they got, and the people making the hiring choices are keenly aware of this.
And when you get beyond your PhD, it's your publication record that people are really going to care about anyway. If you get good papers into good journals, no one gives a crap about your grades.