In this paper, we aim to solve the high dimensional stochastic optimal control problem from the view of the stochastic maximum principle via deep learning. By introducing the extended Hamiltonian system which is essentially a Forward Backward Stochastic Differential Equation (FBSDE) with a maximum condition, we reformulate the original control problem as a new one. According to whether the optimal control has an explicit representation, three algorithms are proposed to solve the new control problem. Numerical results for different examples demonstrate the effectiveness of our proposed algorithms, especially in high dimensional cases. And even if the optimal control \(\tilde{u}\) in the maximum condition may not be solved explicitly, our algorithms can still deal with the stochastic optimal control problem. An important application of our proposed method is to calculate the sub-linear expectations, which correspond to a kind of fully nonlinear Partial Differential Equations (PDEs).