filipstrand / mflux

A MLX port of FLUX based on the Huggingface Diffusers implementation.
657 stars 48 forks source link

Installation (Macbook Pro M3) #44

Closed light-merlin-dark closed 6 days ago

light-merlin-dark commented 1 week ago

First and foremost, thank you for such exquisite tech! πŸ€πŸ™πŸΌπŸŒΉπŸͺ½βœ¨

I'm using a Macbook Pro M3 and here's my experience:

  1. Considered installing native but went for a python vm via python3 -m venv ~/.ai
  2. Ran pip install -U mflux
  3. Encountered the following error:
    
    Collecting mflux
    Downloading mflux-0.2.0-py3-none-any.whl.metadata (19 kB)
    INFO: pip is looking at multiple versions of mflux to determine which version is compatible with other requirements. This could take a while.
    Downloading mflux-0.1.9-py3-none-any.whl.metadata (16 kB)
    ERROR: Cannot install mflux==0.1.9 and mflux==0.2.0 because these package versions have conflicting dependencies.

The conflict is caused by: mflux 0.2.0 depends on mlx>=0.16.0 mflux 0.1.9 depends on mlx>=0.16.0

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip to attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflict



Considerations:
1. I assumed maybe it needed access to my native python libraries for the mlx dependency (not certain).
2. Maybe there was a recent build in your codebase of where this was derived

_*Update*:_

I just discovered that natively my M3 is using a version of python via rosetta, which is x86_64 cpu architecture and possibly where the error is occurring.

Either way, thanks for doing this - it's really cool and I'm looking forward to tinkering with it!

Salud!

πŸŽ©πŸŒΉπŸŒ™πŸͺ½βœ¨ 
filipstrand commented 1 week ago

Hi @light-merlin-dark, I have now updated the readme with an additional instruction of setting up a new virtual environment before installing the project. If you follow these steps does it work for you?

light-merlin-dark commented 1 week ago

Hey @filipstrand good day!

Aye, that was similar to the process I ran yesterday. Only if I'm understanding correctly, it seems my native python env and the venv both are running via rosetta standard on my macbook m3, which may be significant in the context of this error and depending on which code runs internally to check e.g.:

python3 -c "import platform; print(platform.machine())" -> x86_64

arm64

Here's the output I get following the new README:

Screenshot 2024-09-09 at 4 46 57β€―PM

I'm here to help test and try any new approach to resolve it either way. Salud!

πŸŽ©πŸŒΉβ˜€οΈπŸͺ½βœ¨

awni commented 1 week ago

You might find this article on troubleshooting MLX installation useful. Depending on how you installed Python you may need to reinstall.

If you're using conda, something like:

CONDA_SUBDIR=osx-arm64 conda create -n mflux
conda activate mflux
pip install mflux

should work in theory.

Should

light-merlin-dark commented 6 days ago

Hey, @awni. Good day! Aye, thank you! That worked.

For all clarity around this, it didn't seem my Macbook Pro M3 could run this out of the box without a way to get native python to recognize arm support.

Here's what I did to install with success:

  1. I installed miniforge via Github link here
  2. sh Miniforge3-MacOSX-arm64.sh
  3. conda install conda-forge::mlx
  4. CONDA_SUBDIR=osx-arm64 conda create -n mflux
  5. conda activate mflux
  6. conda install pip
  7. pip install mflux

Thanks again for everything. I wish you all a wonderful day or evening!

πŸ€πŸ™πŸΌπŸŒΉπŸͺ½βœ¨