As many as 50 students are reported to have died after armed men stormed a college dormitory in Nigeria's northeast, shooting at them as they slept, according to the Nigerian military.

Sunday's attack, believed to be carried out by the armed group Boko Haram, targeted the College of Agriculture in the town of Gujba in Yobe state, Lazarus Eli, the area military spokesman, said.

"There was an attack at the College of Agriculture in Gujba this morning by Boko Haram terrorists who went into the school and opened fire on students" while they were asleep, Eli said.

Boko Haram is a Nigerian armed group that claims to be fighting Western influence and wants to form an Islamic state.

The literal translation of Boko Haram is "Western education is forbidden".

Molima Idi Mato of the College of Agriculture told AP news agency that classrooms were torched in the attack, which occurred at about 1am local time.

"They attacked our students while they were sleeping in their hostels, they opened fire at them," he said.

He said security forces were still are recovering bodies of students mostly aged between 18 and 22.

The assailants rode into the college in two double-cabin pickup all-terrain vehicles and on motorcycles, some dressed in Nigerian military camouflage uniforms, Ibrahim Mohammed, a surviving student, told the AP.

He said they appeared to know the layout of the college, attacking the four male hostels but avoiding the one hostel reserved for women.

"We ran into the bush, nobody is left in the school now," Mohammed said.

The college is about 40km from the scene of similar school attacks around Damaturu town.

Northeastern Nigeria is under a military state of emergency to battle Boko Haram fighters who have killed more than 1,700 people since 2010 in their quest to install an Islamic state.

Half the country's 160 million citizens are Christian.

Al Jazeera's Ahmed Idris, reporting from Abuja, said that after the country's president declared a state of emergency in May, the military launched a crackdown on armed groups and the situation seemed to have calmed down in the north.

"Then all of a sudden, during the past three or four weeks, incidents started popping up all over the place. Since then, more than 300 people may have been killed by suspected members of Boko Haram," he said.