I am absolutely terrible with names and faces. I simply can't remember them. I will forget the name of my next door neighbor of eight years. I have a friend who has facial blindness and I know that there is a difference with what she has. My own version is closer to facial aphasia (recognizes face but cannot recall name) rather than blindness (cannot recognize face), so please take my comments in that context.
I am upfront with my students about this at the beginning of the semester. I tell them I will forget their names repeatedly, but it doesn't mean I don't care about them. They do get confused because one week I will remember their names and then the next week, it'll be an utter blank. It then becomes a little bit of a running joke in the class but that's ok. I try not to stress too much over it.
Note that there are different strategies for lectures (i.e. big classes where there is minimal expectation that you will have to remember names) and for seminars and discussion groups (where some students will expect you to remember their name). Finally, doctoral students in your own lab will also expect their names to be remembered, but since those are a longer term presence, this can be less of an issue.
Here are some techniques that can be useful for larger classes and for seminars:
As some have mentioned, some course management systems have "photo rosters." I don't find these useful because 1/4 of my students go by nicknames or middlenames that don't show in the CMS. And the photos are very old. And if I could remember someone's name by looking at their face, I wouldn't have this problem to begin with.
You can ask students to always sit in the same seat each day. For seminars, during roll call, I write down the seating arrangement of the students in my roll call chart. In some schools, students have assigned seating. And so instead of recognizing the face, I can associate the seat with the name -- so I ask Jillian-who-sits-in-the-back-left, not Jillian-who-has-a-face-I-can't-remember.
I have asked students who look very similar to sit apart. They giggle and think it's a joke, but after a while they realize I really do have a problem and generally comply.
I ask students to try to wear the same distinctive item. For example, I remembered one student because of the eyeglasses that he wore. The frame stuck better in my mind than his face. When he changed his glasses, 'poof' it was gone.
I ask students for mnemonics. One student named Steve, I only remembered because he was Japanese-American and made a peace sign, so 'V' -> Steve. Some students can come up with good mnemonics, others can not.
You can ask students to have name placards, although most lose them in the first few weeks (and for me, my problem lasts longer than that).
You can ask them to always say their own name when speaking up. In seminar, you can have them say their own name as well as physically say the name of the student who preceded them in a comment: "This is Charlie, I want to follow up with what Alice just said there...."
You can make it a running joke so that the students know that they have to help you constantly. Students are usually surprised when I forget the names of even the most active students in the class, that's when they recognize that it's equal opportunity facial aphasia and that they need to step in to help me.
You can have your teaching fellow help you. For example, if I talk to a student after class and forget their name, I ask my TF to tell me.
In seminar, I occasionally nominated a student to go around the table saying all of the names. It helped when I realized that the students only knew half the names. Better than me, but still it showed that we are all fallible. It also encouraged the quieter students to be more vocal if they wanted to be remembered by their peers.
You can design your classes so that it isn't important for you to have instant recall of their names.
Ask for things in writing. I have trouble remembering the names of students who come up to me after lecture asking for a variance on their grade or attendance policy. I ask them to send such requests to me by e-mail.
You can schedule your office hours so students have to sign up with their names in order to see you (i.e., avoid an 'open door' office policy). That way you can greet them by name (and look up their records) before they come.
For your advisees, you can keep a portfolio on your computer where you record their name, face, year, identifying characteristics (student who always wears a vest, is a smoker (recognize by smell), etc.), and then things about their academic and family life that you'll need the next time you meet them.
In summary, it's not the end of the world and many faculty have difficult with this. Students recognize that they're just one in many. They also recognize the difference between professors who forget who they are because they are apathetic, and faculty who care but genuinely have trouble with this issue. One or two students will consistently raise it in my student evaluations at the end of the semester, but there are enough more positive comments to overwhelm them.
Again, you'll find many faculty with some version of this. You can ask your learning and teaching center at your school for other tips and techniques.
Note: You may want to register this as a disability with the disability office. As a student, you may be able to get some support (i.e., an assistant teaching assistant). As a faculty member, it might be helpful to have this in your file so that student complaints about this do not count against you when you are reviewed for promotion and tenure.