Lattice Boltzmann simulation of cavitating flows