google-deepmind / concordia

A library for generative social simulation
Apache License 2.0
633 stars 148 forks source link

Installing Concordia on M1 Mac - TensorFlow-text does not seem to exist for M1 #37

Closed anatoleg closed 6 months ago

anatoleg commented 7 months ago

Cannot install the gdm-concordia package on an M1 Mac either for Python3.11 or Python3.12. The PIP installer cannot find TensorFlow-text which, apparently, does not exist for M1 Macs. Is there any way around this?

jagapiou commented 7 months ago

I think that dep is needed for the embedder, so until that dep works Concordia doesn't work on M1 macs.

If you can get by without an embedder, cb505d3795e04006206b7d62bb1acd788e64428f might help. You can git clone our repo and pip install from there. That would also allow you to comment out anything else that doesn't work on M1 macs.

jagapiou commented 7 months ago

~#34 adds an alternative embedder, so hopefully that will work soon.~

See code snippet in https://github.com/google-deepmind/concordia/issues/37#issuecomment-2022416660.

anatoleg commented 7 months ago

I assume that the embedder is needed to properly run the provided agent examples. Any chance for a gdm-concordia package release that can be PIP installed on M1 macs?

jzleibo commented 7 months ago

There is a pull request under review right now which will solve this once it's fully incorporated.

jagapiou commented 6 months ago

You can use the following snippet on M1 macs if you install sentence_transformers:

@functools.cache
def embedder(model: str = 'sentence-transformers/sentence-t5-base'):
  return sentence_transformers.SentenceTransformer(model).encode

Thanks @wacunn for this workaround.

anatoleg commented 6 months ago

Thank you @jagapiou. What do I need to do to properly install Concordia instead of "pip install gdm-concordia" as recommended in README? Do I follow the manual install instructions and patch a file (which one)? Thanks again.

jagapiou commented 6 months ago

You can pip install directly from GitHub, or you can git clone it locally and pip install from there (the manual install instructions).

anatoleg commented 6 months ago

Cloned the files and followed the manual install instructions. No installer complaints this time. But the code still blows up on "import tensorflow_text" in embedder_st5.py ("No module named tensorflow_text"). Not clear how to apply the suggested workaround. Should I use a different embedder? Which one? Thanks.

wacunn commented 6 months ago

This is the code that I am using on an M1 Mac.

Setup sentence encoder

from sentence_transformers import SentenceTransformer st5_model = SentenceTransformer('sentence-transformers/sentence-t5-base') embedder = st5_model.encode

anatoleg commented 6 months ago

That worked. I installed sentence_transformers and did not import embedder_st5 from concordia.associative_memory. Used your code instead. Thank you very much.