How many valence electrons does cadmium have?

$2$ valence electrons.
Its electron configuration would be $\left[K r\right] 5 {s}^{2} 4 {d}^{10}$.
So, as with most transition metals, it will have $2$ valence electrons because the full $s$ orbital, which has the highest principal quantum number, has $2$ electrons.