The prediction of the remaining useful life (RUL) is of great significance to ensure the safe operation of industrial equipment and to reduce the cost of regular preventive maintenance. However, the complex operating conditions and various fault modes make it difficult to extract features containing more degradation information with existing prediction methods. We propose a self-supervised learning method based on variational automatic encoder (VAE) to extract features of data's operating conditions and fault modes. Then the clustering algorithm is applied to the extracted features to divide data from different failure modes into different categories and reduce the impact of complex working conditions on the estimation accuracy. In order to verify the effectiveness of the proposed method, we conduct experiments with different network structures on the C-MAPSS dataset, and the results verified that our method can effectively improve the feature extraction capability of the model. In addition, the experimental results further demonstrate the superiority and necessity of using hidden features for clustering rather than raw data.