Artificial intelligence (AI) was one of the driving themes in the market in 2024, powering a number of stocks to new highs. While there remains a lot of hype, AI is looking less like a fad and more like a huge technological shift. Investors who want to profit from it should consider buying these three AI stocks and holding them for the long term.

1. Nvidia

Nvidia (NVDA 4.45%) originally developed its graphics processing units (GPUs) to speed up the rendering of video game graphics. GPUs make use of parallel processing -- breaking complex computational tasks down into many, many smaller tasks that they solve simultaneously.

That's precisely the sort of power that producing high-resolution graphics quickly demands. But most calculations that computers perform don't benefit from that approach. That's why central processing units (CPUs) -- general-purpose chips that can handle most varieties of calculations, and which are fast and powerful when it comes to tackling sequential tasks -- still sit at the heart of most PCs and devices.

When Nvidia recognized that there could be uses for its chips beyond graphics rendering, it created a free software platform called CUDA that customers could use to program its GPUs for other tasks. Eventually, CUDA became an industry standard that developers trained on and grew accustomed to using, enhancing the wide moat Nvidia enjoys today. Meanwhile, its powerful GPUs found uses in more applications. For a time, their use by cryptocurrency miners in particular added to the demand for the fastest GPUs.

It turns out that training and powering AI models involves the types of computations and big data processing that can only be handled efficiently with a parallel processor. So large tech companies began using Nvidia GPUs to train AI models as early as 2015, but after OpenAI introduced ChatGPT to the public in 2022, the AI race was on. Nvidia's GPUs became the backbone of AI infrastructure, and its revenue soared.

Nvidia still has a huge runway for growth in front of it, as the number of GPUs needed to advance AI models continues to rapidly increase. Meta Platforms and Elon Musk-backed xAI are developing new software models using 10 times as many GPUs as they did to develop their prior versions.

With the stock trading a forward price-to-earnings (P/E) ratio of less than 31 based on analysts' 2025 estimates, Nvidia is an attractively valued AI stock that should be a profitable pick to buy now and hold for the long term.

Artist rendering of AI chip.

Image source: Getty Images.

2. Microsoft

Microsoft (MSFT 1.14%) was one of the first big tech companies to commercially embrace AI through its large investment in and partnership with OpenAI. Since Microsoft initiated that relationship, the tech giant has moved quickly on the AI front.

Its cloud computing unit, Azure, has seen strong revenue growth. Azure revenue rose 33% year over year in its fiscal 2025 first quarter (ended Sept. 30), an acceleration from its 29% growth in its fiscal 2024 Q4. Moreover, Azure still faces some capacity constraints given the level of demand from customers that want to build their own AI agents. Management expects Azure's growth to accelerate in the second half of its fiscal 2025 when more capacity comes online.

Microsoft has also been embracing AI in other areas of its business. GitHub, which helps programmers develop software, has seen a huge boost in large part due to the GitHub AI Copilot, which can complete coding tasks or make suggestions to programmers as they type. Meanwhile, the company has also added various Copilots to its productivity suite.

At a current cost of $30 per person per month for enterprise users, the Microsoft 365 Copilot has the potential to be a big revenue growth driver. These tools can do such things as prioritize users' inboxes in Outlook; create PowerPoint presentations based on natural language prompts; suggest rewrites in Word; and allow non-programmers to use Python in Excel using only natural language prompts.

Trading at a forward P/E of 32 times fiscal 2025 estimates, the stock is reasonably priced and looks poised to be a long-term winner.

3. Alphabet

Alphabet's (GOOGL 1.25%) (GOOG 1.31%) cloud computing unit, Google Cloud, has also been seeing accelerating growth: It went from 29% year-over-year growth in Q2 to 35% in Q3. More importantly, the business has reached an important inflection point where its profits have started to grow rapidly. Last quarter, its segment operating income soared to $1.95 billion from $1.2 billion in Q2 and $266 million a year ago as the company leveraged the high fixed-cost nature of this business.

However, it was Alphabet's recent technological advancements that caught investors' attention and powered its stock upward late in 2024. The surge started with the announcement of a big breakthrough in quantum computing with its new Willow chip.

Quantum computing systems thus far have proven error prone, and the more quantum bits (qubits) one uses, the more mistakes it tends to make. However, the new quantum error correction technology on Willow actually reduces the number of errors as it scales up and uses more qubits.

The commercial use of quantum computing is still far away, but it's a huge long-term opportunity, and the breakthrough in error reduction excited investors.

Meanwhile, the company continued to show its technological prowess with its introduction of the AI video generation platform Veo 2. The products of its early demos far outperformed those of OpenAI's Sora, which was launched just a few weeks earlier, in terms of realism and quality. Alphabet also introduced its newest Gemini model, which it will look to incorporate throughout its products this year.

Alphabet continues to be the dominant player in online search, and with Gemini and its AI Overviews, it should be able to create new ad formats to start monetizing queries that it previously hasn't. Historically, Google has only served ads in connection with about 20% of its search results, so the opportunity in monetizing those other queries is huge.

Trading at 18.5 times next year's estimated earnings, Alphabet's stock looks like a bargain.