How to avoid problem of matrix inversion in template attacks

Hi everyone,
I’m trying to reproduce the tutorial Tutorial B8 Profiling Attacks (Manual Template Attack) using 3000 traces with random keys and random plaintext to produce the template model and using the Python script of the tutorial to attack each byte of the 128bits AES Software implementation.
However, I have a matrix inversion problem (the matrix is square but the Det =0) with 3 bytes from the 16 bytes of the 128 bits key.
Does anyone know how to deal with that issue?