In this paper we evaluated several typical matching costs including CENSUS, mutual information (MI) and the normalized cross correlation using the ISPRS Stereo Matching Benchmark datasets for DSM generation by stereo matching. Two kinds of global optimization algorithms including semi-global matching (SGM) and graph cuts (GC) were used as optimization method. We used a sub-pixel method to obtain more accurate MI lookup table and a sub-pixel method was also used when computing cost by MI lookup table. MI itself is sensitive to partial radiation differences. So we used a kind of cost combined MI and CENSUS. After DSM generation, the deviation data between the generated DSM and Lidar was statistics out to compute the mean deviation (Mean), the median deviation (Med), the standard deviation (Stdev), the normalized median absolute deviation (NMAD), the percentage of deviation in tolerance etc., which were used to evaluate the accuracy of DSM generated from different cost.