StableCascade icon indicating copy to clipboard operation
StableCascade copied to clipboard

Requirement torch==2.1.2+cu118 not found

Open tino opened this issue 4 months ago • 10 comments

Running pip install -r requirements.txt on a Mac M1, python 3.11.5, pip==23.2.1, results in:

ERROR: Could not find a version that satisfies the requirement torch==2.1.2+cu118 (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0)
ERROR: No matching distribution found for torch==2.1.2+cu118

Same goes for torchvision==0.16.2+cu118. Dropping the +cu118 makes it install.

tino avatar Feb 14 '24 08:02 tino

Try Python 3.10.x

GTManiK avatar Feb 14 '24 22:02 GTManiK

Same problem here, so tried it with python 3.10 (on M3 Mac).

❯ pip install -r requirements.txt

ERROR: Could not find a version that satisfies the requirement torch==2.1.2+cu118 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0)
ERROR: No matching distribution found for torch==2.1.2+cu118
❯ python --version
Python 3.10.13

❯ pip --version
pip 24.0 from /Users/kenneth/.pyenv/versions/3.10.13/lib/python3.10/site-packages/pip (python 3.10)

kennethgeerts avatar Feb 15 '24 07:02 kennethgeerts

Same issue here on my Mac M1, tried all versions from 3.9 to 3.12

kynnyhsap avatar Feb 15 '24 13:02 kynnyhsap

I may be missing something, but can you even install the cuda component on a Mac, since that is for Nvidia? Came here looking to see if a hack exists to get this on my M3, but seems to me it so far requires an Nvidia GPU to get CUDA, so no Mac support yet. Am I understanding that correctly? Thanks!

rickbarraza avatar Feb 15 '24 14:02 rickbarraza

Looking at ./requirements.txt, we're pointed by --find-links to https://download.pytorch.org/whl/torch_stable.html. There are (understandably) no mac architecture builds for the cuda drivers, thus the failure. I edited the two cuda specific lines to the following to get pip to work:

# torch==2.1.2+cu118
# torchvision==0.16.2+cu118
torch==2.1.2
torchvision==0.16.2

I also saw some mac support code in the new gradio app that I've applied (https://github.com/Stability-AI/StableCascade/blob/master/gradio_app/app.py):

device = torch.device("cpu")
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
    device = torch.device("mps")
if torch.cuda.is_available():
    device = torch.device("cuda")
print("RUNNING ON:", device)

But I don't know if that is the "right" approach. The code itself is broken for me with this error:

untimeError: Error(s) in loading state_dict for StableCascadeUnet:
        size mismatch for embedding.1.weight: copying a param with shape torch.Size([320, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([320, 64, 1, 1]).
        You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.

I haven't been able to resolve this by following the instructions, so I am probably missing something.

damonreed avatar Feb 16 '24 18:02 damonreed

yes same error on Mac for me ..

Cannot load /xxx/.cache/huggingface/hub/models--stabilityai--stable-cascade/snapshots/f2a84281d6f8db3c757195dd0c9a38dbdea90bb4/decoder because embedding.1.weight expected shape tensor(..., device='meta', size=(320, 64, 1, 1)), but got torch.Size([320, 16, 1, 1]). If you want to instead overwrite randomly initialized weights, please make sure to pass both low_cpu_mem_usage=False and ignore_mismatched_sizes=True. For more information, see also: https://github.com/huggingface/diffusers/issues/1619#issuecomment-1345604389 as an example.

But this worked for me for now : https://github.com/Stability-AI/StableCascade/issues/58

ollie2a avatar Feb 17 '24 17:02 ollie2a

#45 also references this fix, but leaves out the --force option, which seems to be required if you need to backrev from a broken version.

Hopefully we'll see a fix in the published current package soon.

damonreed avatar Feb 17 '24 17:02 damonreed

Also, specifically for my Mac peeps: the new gradio app in the latest commit was specifically tested on M2 Max, and I was able to get it up and running on my Mac Studio M2 Max 32GB. You could use that code as a starting point to grab the right values for getting off the ground: https://github.com/Stability-AI/StableCascade/blob/master/gradio_app/app.py

import torch
from diffusers import StableCascadeDecoderPipeline, StableCascadePriorPipeline

device = torch.device("cpu")
if torch.backends.mps.is_available() and torch.backends.mps.is_built():
    device = torch.device("mps")
if torch.cuda.is_available():
    device = torch.device("cuda")
print("RUNNING ON:", device)

c_dtype = torch.bfloat16 if device.type == "cpu" else torch.float
prior = StableCascadePriorPipeline.from_pretrained("stabilityai/stable-cascade-prior", torch_dtype=c_dtype)
decoder = StableCascadeDecoderPipeline.from_pretrained("stabilityai/stable-cascade", torch_dtype=torch.half)
prior.to(device)
decoder.to(device)

Probably veering way off topic at this point, but I wanted to share my findings and a path to working code on the Mac arch.

damonreed avatar Feb 17 '24 20:02 damonreed

I'm also having this issue:

(snap_cluster_setup) brando9@mercury1~/snap-cluster-setup $ pip install torch==2.1.2+cu118
ERROR: Could not find a version that satisfies the requirement torch==2.1.2+cu118 (from versions: 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2)
ERROR: No matching distribution found for torch==2.1.2+cu118

how do I instlal it? i know some ppl I know are using it though https://github.com/stanfordnlp/dspy/discussions/818

brando90 avatar Apr 16 '24 02:04 brando90

https://stackoverflow.com/questions/78331842/how-to-install-pip-install-torch-2-1-2cu118-in-linux

brando90 avatar Apr 16 '24 02:04 brando90