Almost commuting matrices, cohomology, and dimension