Many people would associate artificial intelligence (AI) with chatbots like ChatGPT or even Bard, which was released more recently by Alphabet's Google. It makes sense because the software is consumer-facing. But those platforms wouldn't exist without the advanced semiconductor hardware used to train each AI model.

In fact, investors might find that some of the greatest AI opportunities over the next few years are actually in the hardware space where companies are racing to build infrastructure to support the advanced technology.

Let's look at five stocks involved in AI's hardware space, starting with a name most investors are likely already familiar with.

A digital render of a circuit board with a chip in the center, inscribed with the letters AI.

Image source: Getty Images.

1. Nvidia

The increased hype around AI helped Nvidia (NVDA 6.18%) become synonymous with AI this year, but its history with the technology goes back much further. In fact, Nvidia delivered the first AI supercomputer to OpenAI back in 2016, and Nvidia's graphics processing unit (GPU) chips have been used to train the ChatGPT platform ever since.

Nvidia CEO Jensen Huang estimates there is $1 trillion worth of data center infrastructure in use today that needs to be upgraded to support accelerated computing and AI, and his company has an estimated 90% market share in that segment.

As a result, the world's largest cloud providers are rushing to get their hands on Nvidia's hardware, but some have also partnered with the chipmaker to deliver its DGX supercomputer to their customers. This will enable millions of regular businesses to access the computing power necessary to train their AI models without investing billions of dollars to build the infrastructure.

Nvidia stock has soared 190% this year and officially surpassed a $1 trillion valuation. Its price-to-earnings (P/E) ratio of 139 is over four times more expensive than the 31 P/E of the Nasdaq-100 index. So investors interested in this stock should tread with caution in the short term. But in the long run, I think Nvidia has the potential to eventually become the largest company in the world.

2. Axcelis Technologies

Axcelis Technologies (ACLS 3.06%) is a far smaller company than Nvidia, with a valuation of just $5.4 billion, but its stock has more than doubled this year on the back of an incredibly strong operating performance. Axcelis doesn't produce chips; it's a semiconductor-service company that makes ion implantation equipment critical to the fabrication process.

The world's leading chipmakers will likely experience heightened demand for hardware as AI adoption continues to grow, and they'll need the equipment produced by companies like Axcelis to expand their production capacity. In fact, over the last 12 months, Axcelis received more orders than it can possibly fill, leading to a record-high backlog worth $1.27 billion.

The company generated $922 million in revenue in 2022, representing year-over-year growth of 38%, while many other chip companies were succumbing to the broader economic slowdown. This year, Axcelis expects to deliver $1.03 billion in revenue (a recently lifted forecast) as it continues to work through its order backlog.

Its stock is still very attractive because it trades at a P/E ratio of just 29.2, a slight discount to the Nasdaq-100. As a result, this could be a great time for investors to buy despite its strong gains this year already.

3. Micron Technology

Micron Technology (MU 2.92%) has flown under the radar this year because investors have been focused on semiconductor producers, like Nvidia, making powerful graphics processors for AI workloads. Micron, on the other hand, is a world-leading manufacturer of memory (DRAM) and storage (NAND) chips used in everything from smartphones to data centers to electric vehicles.

But Micron says AI servers can require up to eight times the DRAM content of a regular server and up to three times as much storage, so the company is likely to also benefit from the broader deployment of AI in the long run. In other words, don't sleep on the future potential of this stock.

In the shorter term, Micron is grappling with challenges in its consumer segments, which have slowed significantly because people are simply buying fewer personal computers and devices amid the recent economic slowdown. As a result, Micron found itself with too much inventory, forcing it to mark down prices and eat losses. This triggered a whopping 52% collapse in the company's revenue (year over year) during the fiscal 2023 second quarter (ended March 2).

Micron has also reduced its workforce and cut costs across the board, but here's the good news: It believes inventories have now peaked. As a result, the company's financial results should improve measurably in the coming quarters. And with its stock down 32% from its all-time high, this could be a good chance for investors to buy in ahead of an inevitable demand tailwind from AI over the next few years.

4. Cohu

Cohu (COHU 0.78%) is a semiconductor-service company much like Axcelis Technologies, except it produces testing and handling equipment designed to speed up the quality control process while maintaining its accuracy so that the end-user gets a fully functional chip. Semiconductors are constantly shrinking in size while producing more output, creating an extremely complex manufacturing process. Therefore, advanced technologies are required to ensure the hardware is properly tested and free from defects.

Cohu uses true infrared to see through silicon to detect structural cracks below the surface, which would otherwise be invisible to the naked eye. It also uses AI algorithms to identify scratches as small as 5 micrometers, and it can immediately differentiate between harmless cosmetic issues and serious cracks.

Cohu is also a leader in thermal handlers, which regulate temperatures under test conditions for the high-performance data center chips used for AI applications, which could be a fruitful source of demand going forward.

Wall Street analysts expect Cohu's revenue to drop 14% in 2023 to $695 million amid the tough economic climate, but the company has told investors it could deliver $1 billion in annual revenue, on average, over the next three years. As a result, the company's next phase of growth might be right around the corner.

5. Advanced Micro Devices (AMD)

Advanced Micro Devices (AMD 2.37%) is one of the industry's most popular chip manufacturers, and its hardware powers a number of hot consumer products like Sony's PlayStation 5 and Microsoft's Xbox. But it's also emerging as a key competitor to Nvidia in the AI chips built for data centers.

Earlier this month, the company revealed detailed specifications for its new MI300 chip, which is already slated to power the world's most powerful supercomputer coming online later this year, called El Capitan. Plus, rumors are already flying that the world's largest cloud services provider could be interested in the MI300 after spending years as one of Nvidia's most loyal customers.

The chip comes in multiple configurations, including a first-of-its-kind advanced processing unit that combines central processing unit (CPU) and GPU hardware. It can also be purchased as a standalone GPU, which is what most customers will be looking for. However, it has been designed to require minimal adjustments to existing data center infrastructure to make the upgrade process almost seamless.

The MI300 could be a game changer for AMD as it tries to chip away at Nvidia's dominant market share in this space. AMD stock surged 75% so far this year, though it remains 27% below its all-time high. Over the long term, I think it could soar more than fivefold to catapult the company into the $1 trillion club alongside Nvidia.