After trouncing the market averages in 2023, the stock prices of Advanced Micro Devices (AMD 2.37%) and Nvidia (NVDA 6.18%) are continuing their momentum in 2024. AMD shares are already up 23%, while Nvidia stock is up 26% year to date -- both leaving the S&P 500 index in the dust.

NVDA Chart

Data by YCharts

Investors should always be careful of paying too much for a stock, but there are good reasons to expect these top artificial intelligence (AI) stocks to move higher over the next few years.

Advanced Micro Devices

AMD is a leading supplier of central processing units (CPUs) for PCs and servers, where it is gaining market share against Intel. The company's push into high-performance computing chips has paid off in recent years, but a new year brings new opportunities for this tech innovator.

AMD will try to convert its recent success in CPUs to the data center graphics processing unit (GPU) market to capture the booming market for AI.

A global slowdown in the semiconductor industry pressured AMD's revenue growth over the last year. But leading chip foundry Taiwan Semiconductor Manufacturing issued a positive outlook in its latest earnings report that bodes well for one of its key customers. TSMC manufacturers chips for other companies, including AMD, and said it expects 2024 to be a "healthy" year of growth.

AMD has guided for $2 billion in revenue from data center GPUs this year, as it prepares to launch the new MI300 chip for AI workloads. Meta Platforms, ChatGPT owner OpenAI, and Microsoft are already in line to use the new chips this year.

But AMD is also experiencing a strong recovery in its CPU business. AMD's EPYC server chips grew revenue more than 50% quarter over quarter in 2023's Q3, while its Ryzen 7000 series CPUs for consumer PCs also posted robust growth of 46% sequentially.

The stock is more expensive than Nvidia, trading at a forward price-to-earnings (P/E) ratio of 47. But the combination of a recovering CPU market and growth prospects in AI GPUs are great reasons to consider buying shares for the long haul.

Nvidia

There are good reasons why Nvidia's stock price is still surging to new highs and may be the better buy. It's estimated to control around 90% share of the AI chip market, and the stock is cheaper than AMD, trading at a forward P/E ratio of just 31 based on this year's earnings estimate.

Nvidia has been ahead of the game for many years. Nvidia has long been a favorite brand for PC gamers, and CEO Jensen Huang was early to spot the opportunity in data centers. Over the last few decades, the company has invested over $37 billion in research and development, and that has won Nvidia the top spot in the GPU market.

Other than a cheaper valuation, another reason to like Nvidia is the company's profitability. In addition to chip hardware, Nvidia also supplies networking equipment, software libraries, and development tool kits to help customers solve industry-specific problems. This is an important competitive advantage and explains why Nvidia can earn an impressive software-like profit margin of 42%, compared to AMD's history of generating lower margins.

NVDA Profit Margin Chart

Data by YCharts

It's going to take time for the world's data centers to upgrade their equipment for AI processing. In a recent Instagram post, Meta CEO Mark Zuckerberg noted the social media giant will be using 350,000 of Nvidia's H100 GPUs to build more compute infrastructure to support its future roadmap.

To put that in perspective, a single H100 costs thousands of dollars. The surging demand for these chips pushed Nvidia's data center revenue to $14.5 billion in the October-ending quarter, up from $3.8 billion in the year-ago quarter.

Look for Nvidia's superior profitability and growth to lift the stock to new highs over the next few years, if not through the end of this year.