Upper airway segmentation in static and dynamic MRI is a prerequisite step for quantitative analysis in patients with disorders such as obstructive sleep apnea. Recently, some semi-Automatic methods have been proposed with high segmentation accuracy. However, the low efficiency of such methods makes it difficult to implement for the processing of large numbers of MRI datasets. Therefore, a fully automatic upper airway segmentation approach is needed. In this paper, we present a novel automatic upper airway segmentation approach based on convolutional neural networks. Firstly, we utilize the U-Net network as the basic model for learning the multi-scale feature from adjacent image slices and predicting the pixel-wise label in MRI. In particular, we train three networks with the same structure for segmenting the pharynx/larynx and nasal cavity separately in axial static 3D MRI and axial dynamic 2D MRI. The visualization and quantitative results demonstrate that our approach can be applied to various MRI acquisition protocols with high accuracy and stability.