Thanks to its Ryzen CPUs, AMD has been enjoying time in the spotlight these past few months. Partly due to increasing demand for the new hardware, the company beat expectations for Q2 2017, but it still recorded a slight loss.

AMD reported GAAP earnings of 2 cents per share on revenue of $1.22 billion, marking a 19 percent rise compared to the $1.03 billion it brought in last year. Net loss was $16 million, or 2 cents per share, for the second quarter of 2017. Analysts had been expecting revenue of $1.16 billion and earnings per share of zero.

While the company recorded a profit of $69 million, or 8 cents per share, during the same quarter last year, that included a $150 million pre-tax gain related to its ATMP (assembly, test, mark, and pack) joint venture transaction with Nantong Fujitsu Microelectronics. In the first quarter of 2017, AMD posted a loss of $73 million.

Thanks to Ryzen sales, the company's Computing and Graphics business brought in revenues of $659 million, up 51 percent YoY. The Enterprise, Embedded and Semi-Custom segment revenues of $563 million was down 5 percent this year, mostly due to falling game console sales and the fact AMD's Epyc server chips launched only recently.

Despite the loss, AMD is optimistic about the future. It expects third quarter revenue to increase 23 percent compared to Q2 and has updated its yearly revenue forecast from "low double digits" to a mid- to high-teens percentage.

"We are very pleased with our improved financial performance, including double-digit revenue growth and year-over-year gross margin expansion on the strength of our new products," said AMD CEO Dr. Lisa Su.

The company's shares rose 8.2 percent to $15.27 on the back of the report.