Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it work on M1? #17

Open
eleijonmarck opened this issue Apr 26, 2023 · 3 comments
Open

Does it work on M1? #17

eleijonmarck opened this issue Apr 26, 2023 · 3 comments

Comments

@eleijonmarck
Copy link

No description provided.

@Adreitz
Copy link

Adreitz commented May 2, 2023

I saw jsindy on the IF Discord (April 28) state that they got it working (slowly?) on Mac and posted what I assume to be the Python inference code. I don't know enough about Python to make use of it, though.

I've got an M2 Max with 64 GB unified memory and think that, barring heavy quantization, the Mac is probably the ideal consumer platform to run IF. I just wish there were more evidence of people working on it. I just don't have the expertise or time.

@faxioman
Copy link

faxioman commented May 13, 2023

No luck on an M1.

ysctl hw | grep BF16

returns

hw.optional.arm.FEAT_BF16: 0

So FEAT_BF16 is not supported on M1 but required by the model.

A full example you can try on your M2:

from deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII
from deepfloyd_if.modules.t5 import T5Embedder
from huggingface_hub import login
from deepfloyd_if.pipelines import dream

login("<your hugginface token>", True)

device = 'mps'
if_I = IFStageI('IF-I-XL-v1.0', device=device)
if_II = IFStageII('IF-II-L-v1.0', device=device)
if_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)
t5 = T5Embedder(device="cpu")


prompt = 'ultra close-up color photo portrait of rainbow owl with deer horns in the woods'
count = 1

result = dream(
    t5=t5, if_I=if_I, if_II=if_II, if_III=if_III,
    prompt=[prompt]*count,
    seed=42,
    if_I_kwargs={
        "guidance_scale": 7.0,
        "sample_timestep_respacing": "smart100",
    },
    if_II_kwargs={
        "guidance_scale": 4.0,
        "sample_timestep_respacing": "smart50",
    },
    if_III_kwargs={
        "guidance_scale": 9.0,
        "noise_level": 20,
        "sample_timestep_respacing": "75",
    },
)

if_III.show(result['III'], size=14)

If you don't have enough RAM, you can also try with the only if_I.

This is the setup (python 3.10.11 installed with pyenv):

pip install deepfloyd_if==1.0.2rc0
pip install xformers==0.0.16
pip install git+https://github.com/openai/CLIP.git --no-deps
pip install protobuf==3.20.3

@brkirch
Copy link

brkirch commented May 13, 2023

https://github.com/brkirch/DeepFloyd-IF-example-Mac

It will require 64 GB of RAM due to the Diffusers SD x4 upscaler pipeline being very memory inefficient on MPS. Only using the stage I and stage II models requires 32 GB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants