We study the problem of whether a given finite algebra with finitely many basic operations contains a cube term; we give both structural and algorithmic results. We show that if such an algebra has a cube term then it has a cube term of dimension at most N, where the number N depends on the arities of basic operations of the algebra and the size of the basic set. For finite idempotent algebras we give a tight bound on N that, in the special case of algebras with more than \(\left( {\begin{array}{c}|A|\\ 2\end{array}}\right) \) basic operations, improves an earlier result of K. Kearnes and Á. Szendrei. On the algorithmic side, we show that deciding the existence of cube terms is in P for idempotent algebras and in EXPTIME in general. Since an algebra contains a k-ary near unanimity operation if and only if it contains a k-dimensional cube term and generates a congruence distributive variety, our algorithm also lets us decide whether a given finite algebra has a near unanimity operation.