The fifth-generation (5G) mobile network enhances network connectivity between many mobile devices by utilizing higher bandwidth with lower communication delay. This massive connectivity generates huge network traffic while burdening the base station (BS). Hence, it is required to offload the BS and enhance the system’s overall performance. Device-to-device (D2D) communication is the prominent solution to offload the network traffic and enhance spectrum efficiency. However, D2D communication significantly disadvantages resource allocation while operating in underlay mode. A prominent solution is to embrace artificial intelligence (AI) in the D2D environment to tackle resource allocation issues. This paper exhaustively surveys all AI-based resource allocation schemes researchers have proposed globally. We found that no exhaustive literature surveys discuss the role of AI in resource allocation in a D2D environment. Thus, this motivated us to prepare a comprehensive survey and propose an AI-based resource allocation taxonomy comprising channel, power, and spectrum allocation. We also discuss the various real-time applications of AI-driven schemes for efficient resource allocation in D2D communication. Further, we presented a case study highlighting AI’s role in efficient resource allocation in D2D communication. Here, we used a novel channel quality indicator (QI) that uses signal-to-noise ratio (SINR) and signal-to-noise-and-distortion Ratio (SNDR) to decide the best D2D users for the resource allocation process. Then, we discussed the open research challenges that point to the future research direction in AI-based efficient resource allocation in D2D communication.