The invention discloses a D2D resource allocation method based on multi-agent deep reinforcement learning, and belongs to the field of wireless communication. The method comprises the following steps:firstly, constructing a heterogeneous network model of a cellular network and D2D communication shared spectrum; establishing a signal to interference plus noise ratio (SINR) of a D2D receiving userand an SINR of a cellular user based on the existing interference, respectively calculating unit bandwidth communication rates of a cellular link and a D2D link, and constructing a D2D resource allocation optimization model in a heterogeneous network by taking the maximum system capacity as an optimization target; For the time slot t, constructing a deep reinforcement learning model of each D2D communication pair on the basis of the D2D resource allocation optimization model; And respectively extracting respective state feature vectors from each D2D communication pair in the subsequent time slot, and inputting the state feature vectors into the trained deep reinforcement learning model to obtain a resource allocation scheme of each D2D communication pair. According to the invention, spectrum allocation and transmission power are optimized, the system capacity is maximized, and a low-complexity resource allocation algorithm is provided.