gemma icon indicating copy to clipboard operation
gemma copied to clipboard

Mutex issue when constructing gemma model object

Open sidwan02 opened this issue 3 months ago • 3 comments

I'm running into a mutex issue when constructing the gemma model object:

libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
Abort trap: 6

Reproduce:

from gemma import gm

model = gm.nn.Gemma3_4B()
params = gm.ckpts.load_params(gm.ckpts.CheckpointPath.GEMMA3_4B_IT)

Spec:

  • Mac M3 Pro with JAX installed for CPU
  • Python 3.13.7

How can I provide additional information to help debug this setup issue? Thanks!

sidwan02 avatar Sep 30 '25 00:09 sidwan02

Hi @sidwan02 ,

The above mentioned code snippet is running fine without any issues on the free Colab notebook. The possible workaround could be following:

A common solution is to isolate the conflicting libraries. If you installed JAX for CPU, you might be hitting a generic macOS/JAX issue.

  1. Use a different environment/Python version: Try setting up a completely fresh virtual environment with a slightly different Python version (e.g., Python 3.11 or 3.12, if 3.13 is new for your setup).

  2. Check for PyArrow/TensorFlow conflicts: If you have PyArrow or TensorFlow installed (even if you don't use them directly), try upgrading or downgrading them, as they are often the source of these low-level C++ conflicts on Mac.

Thanks.

I'm running into this as well, also on Apple silicon (Python 3.12.12).

Apparently it happens when libprotobuf is concurrently linked by multiple packages, and something about it changed in TensorFlow 2.20.

Here is a bunch of related issues:

  • https://github.com/tensorflow/tensorflow/issues/98563
  • https://github.com/tensorflow/tensorflow/issues/99464
  • https://github.com/apache/arrow/issues/40088
  • https://github.com/protocolbuffers/protobuf/issues/21686

So far, I managed to solve mutex lock failed: Invalid argument by constraining tensorflow<2.20.

Unfortunately, I get [mutex.cc : 452] RAW: Lock blocking 0x... @ instead now. Someone suggested using pyarrow 17.0.0, but that didn't work for me.

kkom avatar Oct 19 '25 21:10 kkom

Upgrading to pyarrow 22.0.0 fixed it for me.

chrisfougner avatar Oct 29 '25 13:10 chrisfougner