The movie is probably I Am Legend, starring Will Smith.
Will Smith is an Army scientist who survives a plague that kills most of the population and turns the rest into monstrous vampires. His daughter's dog is his only companion, and dies trying to defend him.
In 2009, a genetically re-engineered measles virus, originally created as a cure for cancer, turns into a lethal strain which kills 90% of those it infects, and mutates the remaining 10% into predatory, nocturnal mutants called "Darkseekers" who are extremely vulnerable to sunlight and other sources of UV. Three years after the outbreak, US Army virologist Lieutenant Colonel Robert Neville (Will Smith) lives an isolated life in the ruins of New York City, which is now deserted, unsure if any other uninfected humans are left in the world.
The (mediocre) movie is very loosely based on the (excellent) Richard Mattheson book of the same name.