This paper focuses on optimal transmit power allocation to maximize the overall system throughput in a vehicle-to-everything (V2X) communication system. We propose two methods for solving the power allocation problem namely the weighted minimum mean square error (WMMSE) algorithm and the deep learning-based method. In the WMMSE algorithm, we solve the problem using block coordinate descent (BCD) method. Then we adopt supervised learning technique for the deep neural network (DNN) based approach considering the power allocation from the WMMSE algorithm as the target output. We exploit an efficient implementation of the mini-batch gradient descent algorithm for training the DNN. Extensive simulation results demonstrate that the DNN algorithm can provide very good approximation of the iterative WMMSE algorithm yet reducing the computational overhead significantly.