The FBI have said that while it is too early to speculate on the motive for a deadly shooting at a bar in southern California, the gunman appeared to have acted alone.

A former US Marine opened fire in a bar popular with college students last night, killing 12 people including a sheriff's deputy.

The gunman, identified by authorities as Ian David Long, 28, was found dead in the office of the Borderline Bar and Grill, located in Thousand Oaks, a suburb about 64km northwest of Los Angeles after the incident.

Police believe he took his own life.

Ventura County Sheriff Geoff Dean said Long had apparently fired at random with a.45-caliber Glock handgun with an extra-capacity magazine.

"Obviously he had something going on in his head that would cause him to do something like this," Sheriff Dean said.

Long was in the Marine Corps from 2008 to 2013, reaching the rank of corporal, and served as a machine gunner who was deployed to Afghanistan for eight months.

Sheriff Dean said it was possible that Long had suffered from post-traumatic stress disorder.

He told reporters that officers had gone to Long's home in nearby Newbury Park, about 6km from the bar, in April to answer a disturbance call and found him to be agitated.

Mental health specialists talked with Long and determined that no further action was necessary.

The bar shooting was the latest mass killing in the United States and was sure to revive the debate on gun control.

Less than two weeks ago 11 worshippers at a synagogue in Pittsburgh were killed by a man shouting "All Jews must die."

The Borderline is popular with university students and last night hosted College Country Night.

California Lutheran University, located about 8km from the bar, cancelled classes today while Pepperdine University, about 32km away, planned a prayer service.

One of those in the bar last night said he saw the gunman walk in and stop at the counter, apparently paying a cover charge.

Cole Knapp, 19, said he then heard gunfire.

"It took a couple of seconds for people to realise what was going on and once that happened it was just utter chaos," he said.

Mr Knapp said he first helped people hide behind a pool table and then fled to the bar's outdoor smoking patio, where people were unaware of the shooting.

Once outside, he said he and a friend helped carry a gunshot victim to an ambulance.

"I'm just reeling, riding on adrenaline right now," he said.

"It's just kind of unbelievable that somebody would want to come to a place I care about and hurt people that I care about."

Thousand Oaks, with a population of about 127,000, is a leafy, sprawling suburb named the third safest city in the United States for 2018 by Niche, a company that researches schools, income, real estate, crime and other livability factors in ranking cities.

"I've learned it doesn't matter what community you're in," Sheriff Dean told reporters when asked if he was surprised this happened in Thousand Oaks.

"It doesn’t matter how safe your community is. It can happen anywhere."

One man, Jason Coffman, told reporters that his son, Cody, 22, was among the dead.

"This is going to be an absolutely heart-wrenching time for me and my family," Mr Coffman said.

"This is a heart that I will never get back."

Names of the victims were not immediately made public and about 60 people were gathered at a teen centre in Thousand Oaks waiting to learn if their loved ones were among the dead.

After families were briefed, one man sat outside on the curb sobbing loudly.

Ventura County Sheriff's Office Sergeant Ron Helus, a 29-year veteran, was one of the first law enforcement officials to reach the Borderline after the first 911 calls were made.

Sergeant Ron Helus died in the shooting

He was shot in the bar and died in hospital, Sheriff Dean said.

"Ron's selfless, heroic actions will never be forgotten," a  statement from the Sheriff’s office read. He is survived by a wife and son.

Asked what the scene inside the bar was like, Sheriff Dean said, "Like ... hell."

He said he had been told 150 to 200 people were in the Borderline at the time.

"It could have been much, much worse," he said.

Sheriff Dean estimated ten to 15 people, including one with a gunshot wound, had gone to hospitals.

He said he believed their injuries were minor, and that most were likely injured as they escaped, some by breaking windows.

Jennifer Avalos, 20, held back tears as she left the teen centre, where she had hoped to learn the fate of her friend, Noel Sparks, 21, who had been at Borderline.

They had texted each before the shooting but Mr Sparks did not come home.

President Donald Trump, who has resisted a surge in calls for tougher gun control measures since 17 students and staff were shot dead at Stoneman Douglas High School in Florida earlier this year, ordered flags to be flown at half-mast at public buildings and grounds.