One gunman, later identified as a Georgian national, opened fire at the academy and then shot himself, the ANS channel reported. Other reports said two gunmen were involved in the attack.
The gunman was reported to have killed a security guard and cleaner after entering the academy and continued shooting indiscriminately at students and staff from a Makarov pistol while going up a staircase.
A police officer said the attacker climbed up to the sixth floor and shot himself in one of the classrooms there.
The Interior Ministry said the police operation had ended, promising to release details of the incident later.
Television reports said Azerbaijani, Turkish and Syrian nationals were among the dead. The academy is a major international center training oil industry specialists.