  Let k be a non archimedean field. If X is a k-algebraic variety and U a
locally closed semi-algebraic subset of X^{an} -- the Berkovich space
associated to X -- we show that for l \neq char(\tilde{k}), the cohomology
groups H^i_c (\bar{U}, Q_l) behave like H^i_c(\bar{X}, Q_l), where \bar{U} = U
\otimes \hat{\bar{k}}. In particular, they are finite-dimensional vector
spaces. This result has been used by E. Hrushovski and F. Loeser. Moreover, we
prove analogous finiteness properties concerning rigid semi-analytic subsets of
compact Berkovich spaces (resp. adic spaces associated to quasi-compact
quasi-separated k-rigid spaces) when char(\tilde{k}) \neq 0 (resp in any
characteristic).
