Warren Buffett and tech stocks go together like...well, they usually don't go together. The legendary investor typically avoids stocks that are out of his wheelhouse. And tech isn't his strong suit.

Unsurprisingly, Buffett doesn't own a single share of Nvidia (NVDA -1.91%). So, has he missed out on the artificial intelligence (AI) stock's massive gains over the last few years? Not entirely.

Buffett's direct ways of profiting from Nvidia

Although Buffett doesn't own any shares of Nvidia, Berkshire Hathaway's portfolio includes two exchange-traded funds (ETFs) that do. As a result, he has directly profited as Nvidia stock has skyrocketed.

Nvidia was added to the S&P 500 in 2001, replacing the beleaguered energy company Enron. In the fourth quarter of 2019, Berkshire initiated positions in two S&P 500 index ETFs -- the SPDR S&P 500 ETF Trust (SPY 0.16%) and the Vanguard S&P 500 ETF (VOO 0.15%). The conglomerate hasn't sold shares of either ETF since then.

Granted, Buffett hasn't directly profited very much from Nvidia's gains via Berkshire's stakes in these two S&P 500 index ETFs. For one thing, Berkshire owns only small positions in the funds -- 39,400 shares of the SPDR ETF and 43,000 shares of the Vanguard ETF. These holdings comprise less than 0.1% of Berkshire's total portfolio. For several years, Berkshire's wholly owned subsidiary, New England Asset Management (NEAM), has also owned positions too small to move the needle much in both ETFs.

Additionally, Nvidia makes up only 7.25% of the S&P 500, which is weighted based on market cap. When Berkshire first bought the two S&P 500 ETFs in late 2019, the AI stock had a much smaller weight than it does now.

How the "Oracle of Omaha" has indirectly profited from Nvidia

Buffett has indirectly profited from Nvidia's remarkable rise, too. Exactly how he's done so requires some deductive analysis.

Let's start with the fact that the stocks of the leading cloud services providers have performed exceptionally well recently. Shares of Amazon (AMZN 2.19%), whose Amazon Web Services (AWS) is the top cloud service platform, skyrocketed 81% last year and more than 20% year to date. Microsoft (MSFT 0.15%) stock jumped 57% in 2023 and is up almost 20% this year. Alphabet (GOOG 0.80%) (GOOGL 0.83%), which operates Google Cloud, has seen its shares soar 58% last year and more than 25% so far in 2024.

There's no question that the AI boom, especially with the surging adoption of generative AI, has been a key factor in the performance of all three cloud stocks. Importantly, Amazon, Microsoft, and Alphabet are major customers of Nvidia. The three companies almost certainly wouldn't have been able to handle the increased demand for cloud services with Nvidia's AI chips.

I think it's fair to say, therefore, that Nvidia is partly responsible for the share price gains experienced by Amazon, Microsoft, and Alphabet. However, how much of those gains can be attributed to Nvidia is hard to determine.

So, how does this tie in with Buffett? First, Berkshire owns 10 million shares of Amazon. Second, NEAM (Berkshire's subsidiary) owns positions in Alphabet and Microsoft. Third, all three cloud stocks are also key holdings of Berkshire's two S&P 500 index ETFs.

You might have made money from Nvidia in the same ways

It's possible (and perhaps even probable) that you're in the same position as Buffett -- profiting from Nvidia without owning the stock. The SPDR S&P 500 ETF Trust is the largest ETF based on assets under management, while the Vanguard S&P 500 ETF ranks third. Even if you don't own either ETF, your investment portfolio could include one or more other ETFs or mutual funds with positions in Nvidia.

Amazon, Alphabet, and Microsoft are also widely owned stocks. You could either directly own some or all of them or own funds with stakes in the megacap stocks.

To be sure, these ways of making money from Nvidia aren't nearly as rewarding as owning shares of the graphics processing unit (GPU) maker. But it could at least provide some consolation for investors who have kicked themselves for not buying Nvidia sooner. It also underscores one of the advantages of investing in S&P 500 index ETFs: Big winners like Nvidia garner increasingly higher weights in the index as their market caps grow -- and can make you more money in the process.