Firefighters struggling with rough terrain sought to gain ground against a raging wildfire that reached the western edge of California's Yosemite National Park.

The blaze, burning mostly in the Stanislaus National Forest in northern California just outside Yosemite, tripled in size overnight to cover 54,000 acres.

Thousands of residents have been asked to evacuate the area.

National Interagency Fire Center spokesperson Robyn Broyles said the blaze is the fourth-largest and fastest growing wildfire in the US.

It is one of 50 large wildfires burning throughout the western US.

US Forest Service spokesman Trevor Augustino said the fire was only 2% contained, despite efforts of more than 1,360 firefighters to tame it.

California Governor Jerry Brown yesterday declared a state of emergency in Tuolumne County, where the fire is burning.

Mr Augustino said the Rim Fire, named after a popular lookout point, Rim of the World, is burning on rugged and remote terrain, which has made it challenging for firefighters to haul in hoses.

On Wednesday, the fire had been 5% contained and ranged across only 16,000 acres, but it has since grown in size and the containment level has dropped.

Wildfire managers look to military, Canada for aid

US wildfire managers facing increasingly strained resources have opened talks with Pentagon commanders and Canadian officials about possible reinforcements of personnel and aircraft to battle dozens of blazes raging across the western US.

Elite teams of firefighters known as hotshots and smoke jumpers, whose job it is to mount the initial attack on blazes in remote, rugged terrain, are stretched too thin, said Stephen Gage, assistant operations director for fire and aviation management for the Forest Service.

The agency's 100-plus hotshot crews are all either assigned to fires in the west or are taking required periods of rest and recovery, leaving no spare teams to dispatch to any additional fires where they might be needed, he said.

Fire managers are poised to decide in coming days whether to "pull the trigger" on a pending request to the US military for an initial deployment of 200 ground troops to supplement firefighting personnel, Mr Gage said.

It would take roughly a week to train and mobilise those troops, who would then be assigned to large fires in the west.

Thousands of firefighters were trying to suppress dozens of blazes raging in several western states, from a monster fire menacing the area around the world-class ski resort in Sun Valley, Idaho, to the blaze near Yosemite National Park.