Nvidia (NVDA 6.18%) and Baidu (BIDU 0.62%) represent two different ways to invest in the growing artificial intelligence (AI) market. Nvidia is the world's largest producer of high-end data center graphics processing units (GPUs) for undertaking AI tasks. Baidu, which owns China's largest search engine, has also established a foothold in the market with its cloud-based AI services, ERNIE chatbot, and Apollo platform for driverless vehicles.

But over the past 12 months, Nvidia's stock more than tripled as Baidu's stock rallied less than 30%. Let's see why the chipmaker outperformed the Chinese tech giant by such a wide margin -- and whether it's still the better buy.

A group of robots working on laptops in an office.

Image source: Getty Images.

Why did Nvidia's stock skyrocket?

Nvidia's revenue stayed flat in fiscal 2023, which ended last January, as the macro headwinds throttled the growth of its data center business. Weak sales of PCs in a post-pandemic market exacerbated that pain by reducing its sales of gaming GPUs.

Yet, Nvidia's growth accelerated throughout its fiscal 2024, and the company now expects revenue to rise about 118% for the full year. That explosive growth was driven by the rapid expansion of the generative AI market, which sent companies scrambling to upgrade their servers with Nvidia's data center chips. Nvidia generated 80% of its revenue from its data center chips in its latest quarter.

All the world's leading generative AI platforms -- including OpenAI's ChatGPT -- are currently powered by Nvidia's GPUs. That "best in breed" reputation made Nvidia an obvious play on the booming generative AI market, which Fortune Business Insights expects to expand at a staggering compound annual growth rate (CAGR) of 47.5% from 2023 to 2030. Nvidia's gaming business is also recovering as the PC market finally stabilizes.

Nvidia's pricing power and scale enabled it to expand its margins consistently, and analysts expect its adjusted earnings per share (EPS) to nearly triple in fiscal 2024. If we take into account that breakneck growth, its stock doesn't seem that expensive at 31 times forward earnings.

Why didn't Baidu attract as much attention?

Baidu didn't generate as much excitement as Nvidia for three reasons. First, it still generated most of its revenue from its online marketing business -- which includes its core search engine, portal sites, and managed pages -- instead of its cloud and AI services. Second, its growth was throttled by the macro headwinds and intermittent COVID lockdowns in China, which caused its revenue to dip 1% in 2022.

Lastly, Baidu's business could be disrupted by the escalating tech war between the U.S. and China. The latest export curbs could block Baidu from obtaining Nvidia's latest chips to expand its cloud and AI services, while U.S. regulators are still threatening to delist its shares from the NASDAQ if it doesn't comply with tighter auditing standards.

Despite all those challenges, Baidu returned to growth in the first three quarters of 2023 as its online marketing business stabilized. The stabilization offset its decelerating growth in non-online marketing revenues (including its AI Cloud services) -- largely caused by a slowdown in "smart transportation" projects (i.e., driverless cars) across China. It expects those headwinds to reduce its AI cloud revenues through the end of the year.

Analysts expect Baidu's revenue and adjusted EPS to grow 5% and 21%, respectively, in 2023 as it faces some easy year-over-year comparisons to 2022. Those growth rates seem stable, and its stock looks cheap at 12 times forward earnings.

The better buy: Nvidia

Investors were clearly more impressed by Nvidia's direct exposure to the growing AI market than Baidu's lower exposure through its AI Cloud division. Nvidia is also growing faster, doesn't face meaningful competitors in the AI chip market, isn't dependent on the macro-sensitive advertising market, and is well diversified globally. Baidu still generates most of its revenue in China, where it faces plenty of formidable competitors across the advertising, cloud, and AI markets.

Therefore, it's easy to see why Nvidia outperformed Baidu over the past year. Looking ahead, I believe Nvidia will stay ahead of Baidu and remain a better overall play on the growing AI market. Baidu might be the cheaper stock right now, but it will keep trading at that discount until its growth accelerates and the regulatory headwinds dissipate.