TORONTO — Long before Google started working on cars that drive themselves and Amazon was creating home appliances that talk, a handful of researchers in Canada — backed by the Canadian government and universities — were laying the groundwork for today’s boom in artificial intelligence.

But the center of the commercial gold rush has been a long way away, in Silicon Valley. In recent years, many of Canada’s young A.I. scientists, lured by lucrative paydays from Google, Facebook, Apple and other companies, have departed. Canada is producing a growing number of A.I start-ups, but they often head to California, where venture capital, business skills and optimism are abundant.

“Canada is not really reaping the benefits from this A.I. technical leadership and decades of investment by the Canadian government,” said Tiff Macklem, former senior deputy governor of the Bank of Canada, who is dean of the Rotman School of Management at the University of Toronto.

Now bringing A.I. home is a priority for the Canadian government, companies, universities and technologists. The goal, they say, is to build a business environment around the country’s expertise and to keep the experts its universities create in the country.

And they want to build on the tenacity of veteran researchers like Geoffrey Hinton, Richard Sutton and Yoshua Bengio, who developed techniques that opened the door to remarkable improvements in an A.I. technology called machine learning, even as many computer scientists and the tech industry considered their work to be an unpromising backwater.

There are encouraging signs, including new government funding, big company investments, programs to nurture start-ups, and the changing habits of homegrown entrepreneurs and American venture capitalists.

In its new budget, the government of Prime Minister Justin Trudeau pledged $93 million ($125 million Canadian) to support A.I. research centers in Toronto, Montreal and Edmonton, which will be public-private collaborations.

The Vector Institute for Artificial Intelligence in Toronto, announced two weeks ago, will be one of them. The institute begins with commitments of $130 million, about half the money coming from the national and provincial governments and the other half from corporate sponsors like Google, Accenture and Nvidia, as well as big Canadian companies like the Royal Bank of Canada, Scotiabank and Air Canada.

Mr. Hinton, who was hired by Google in 2013 but remains a professor at the University of Toronto, will serve as its chief scientific adviser. The new institute will be in the Mars Discovery District, a cluster of buildings in downtown Toronto, run by a public-private partnership, that is home to many tech start-ups including A.I. companies..

Major technology companies, like Google, Microsoft and IBM, are adding to their A.I. research teams in Canada. So are companies in other industries.

Last year, General Motors said it was going to locate one of its research and engineering hubs for self-driving cars in the Toronto suburb of Markham. And Thomson Reuters announced it would open a center for “cognitive computing” in Toronto for research into new ways professionals will use information and technologies to assist decision making.

Building businesses that use A.I. is an economic imperative for Canada. The Canadian tech industry has stalled in recent years. Nortel, Canada’s big telecommunications equipment maker, declared bankruptcy in 2009, and was wound down over the next several years. And BlackBerry, once a leader, has faded in the smartphone market.

The experience of two start-ups applying A.I. technology to drug discovery illustrate the challenges — and the opportunities — facing Canadian start-ups.

Atomwise, a company that uses A.I. technology to predict what new molecules might combat specific diseases like multiple sclerosis, was founded in 2012. Its chief executive, Abraham Heifets, earned his Ph.D. in computer science from the University of Toronto.

When Mr. Heifets sought funding, he recalled, one potential Canadian investor said people had tried the same thing 20 years ago. “What could possibly be new?” Mr. Heifets said the investor had asked, and turned him down.

Later, Mr. Heifets went to the Bay Area and met with Timothy Draper, founder of the venture capital firm Draper Fisher Jurvetson. Mr. Draper observed that he had invested in a couple of companies trying a similar approach 20 years ago. That didn’t deter him from trying again.

“That’s a cultural issue, a different appetite for risk and willingness to accept failure,” Mr. Heifets said.

Atomwise moved to San Francisco to be close to its investors and the region’s enormous talent pool.

By contrast, Deep Genomics, founded in 2014, has stayed in Canada, and its American-based venture backers encouraged it to remain in Toronto.

Brendan Frey, the chief executive, studied under Mr. Hinton at the University of Toronto, and he has spent years on research that combines deep-learning A.I. and cell biology. When he hires software engineers, he asks them to make multiyear commitments.

“There are a lot of distractions in the Bay Area,” said Mr. Frey, who is also a professor at the University of Toronto and a co-founder of the new Vector institute. “The hype is a little too hot down there. Besides, we have some of the best talent in the world here.”

Both Atomwise and Deep Genomics were participants in different years in a program called the Creative Destruction Lab. Founded in 2012 by Ajay Agrawal, a professor at the Rotman School, the lab was set up to help technology-intensive start-ups. They are typically founded by a Ph.D. scientist who has worked on an idea for five years, but has little or no business experience.

In 2015, the program tilted toward A.I. start-ups, with 25 companies admitted. Last year, 50 A.I. start-ups were admitted, and this year will likely have 75, Mr. Agrawal said.

The program lasts nine months, with fall and spring terms, much like a school year. The participants gather every eight weeks in Toronto for two days to make presentations, listen to advice and set goals for the next eight weeks.

At every gathering, at least one and sometimes several companies are voted out. The voters are a growing group of tech entrepreneurs and investors whom Mr. Agrawal has recruited.

One of the X factors in Canada’s drive to develop an A.I. industry is the Trump administration. Canadian A.I. scientists say they have received a stream of inquiries from researchers in the United States, concerned about the new administration’s stance on immigration and other policies.

Should there be a northward migration it wouldn’t the first time. Mr. Hinton settled in Canada in 1987 in part because of America’s clandestine support for the Contra guerrillas who sought to overthrow the left-wing Sandinista government in Nicaragua.

Mr. Hinton, who is from Britain, was at Carnegie Mellon University at the time, and he realized that continuing his research in America would have meant accepting funding from the Reagan administration. “I preferred Canada,” Mr. Hinton recalled.

Mr. Sutton left the United States to become a professor at the University of Alberta in 2003, after American troops landed in Baghdad. “George Bush was invading Iraq,” he said. “It was a good time to leave.”