With the increasing number of vehicles and the shortage of spectrum resources, the development of the Internet of vehicles is severely limited. Based on game theory, this paper proposes a dynamic allocation scheme of spectrum resources in the congestion scenario. Different from the traditional spectrum resource allocation scheme, the scheme gives users cognitive ability to realize dynamic and intelligent efficient utilization of spectrum resources without relying on the central node and the mutual transmission of channel information between users. In a dense scenario where the number of wireless resources is less than the number of users, the scheme can automatically screen out the users with more advantageous communication conditions to enhance the overall communication capacity of the system. Simulation results show that the algorithm can automatically filter out the channels with relatively better conditions, and can effectively avoid the interference between different users, which is highly efficient.