Algorithm error: LaTex error: \caption outside float

When writing a paper with a template, algorithm error was found:
LaTex error: \caption outside float
should be algorithm in the CLS file of the template itself, resulting in a conflict, so the following package was added:

\usepackage[algo2e,ruled,vlined]{algorithm2e}

And clearly

\begin{algorithm2e}

\end{algorithm2e}

Can be solved!

Read More: