M.2 NVMe SSD (Non-Volatile Memory express Solid-State Drive), which have higher computational speed and reliability than conventional devices, have come to be widely used. Recent studies have reported that M.2 NVMe SSD are beginning to have thermal issues due to the increasing heat generation occurring with the high chip density and high-performance operation in a limited space. Thermal issues in the controller and memory units of M.2 NVMe SSD lead to increased failure rates and decreased data retention times. In this study, we propose a compact and optimized thermal solution for commercial M.2 NVMe SSD installed between the mainboard and GPU (Graphic Processing Unit). A thermal and fluid dynamics simulation of an M.2 NVMe SSD, including the heatsink, was performed, and the Genetic Algorithm method was used to optimize the heatsink size.