CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
68.01k stars 10.13k forks source link

Failure creating conda env on OSX amd64 - ResolvePackageNotFound: cudatoolkit=11.3 #309

Open ivandov opened 2 years ago

ivandov commented 2 years ago

Following the guide in the README.md, I attempted the following command and received an error:

conda env create -f environment.yaml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound:
  - cudatoolkit=11.3

Machine Details

ssunday commented 2 years ago

I am receiving this error as well via the miniconda installer.

rogersanick commented 2 years ago

+1 I'm having this issue on an Intel mac

rathinho commented 2 years ago

having this problem as well

rathinho commented 2 years ago

and the newest version of cudatoolkit for osx64 is 9.0 (check HERE).

I tried to set "- cudatoolkit=9.0" in environment.yaml and got this error:

Traceback (most recent call last):
  File "scripts/txt2img.py", line 346, in <module>
    main()
  File "scripts/txt2img.py", line 242, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 65, in load_model_from_config
    model.cuda()
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 127, in cuda
    return super().cuda(device=device)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 601, in _apply
    param_applied = fn(param)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py", line 210, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
kencanak commented 2 years ago

and the newest version of cudatoolkit for osx64 is 9.0 (check HERE).

I tried to set "- cudatoolkit=9.0" in environment.yaml and got this error:

Traceback (most recent call last):
  File "scripts/txt2img.py", line 346, in <module>
    main()
  File "scripts/txt2img.py", line 242, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 65, in load_model_from_config
    model.cuda()
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 127, in cuda
    return super().cuda(device=device)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 601, in _apply
    param_applied = fn(param)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py", line 210, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

this patch will https://github.com/ModeratePrawn/stable-diffusion-cpu/pull/1/files run on CPU when GPU is not enabled. it will take approx an hour to generate results

rathinho commented 2 years ago

and the newest version of cudatoolkit for osx64 is 9.0 (check HERE). I tried to set "- cudatoolkit=9.0" in environment.yaml and got this error:

Traceback (most recent call last):
  File "scripts/txt2img.py", line 346, in <module>
    main()
  File "scripts/txt2img.py", line 242, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 65, in load_model_from_config
    model.cuda()
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 127, in cuda
    return super().cuda(device=device)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 601, in _apply
    param_applied = fn(param)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py", line 210, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

this patch will https://github.com/ModeratePrawn/stable-diffusion-cpu/pull/1/files run on CPU when GPU is not enabled. it will take approx an hour to generate results

it works! and as you said, it's extremely slow..

Merkwurdichliebe commented 2 years ago

Same issue here. macOS 12.5.1 Intel i7 AMD Radeon R9 M395.

danielcaldas commented 2 years ago

+1

haroldlbrown commented 2 years ago

I have this error both with anaconda and with miniconda. 😐

mlynch commented 1 year ago

Getting this as well. Looks like the issue is that there's no 11.3 build for Mac yet, even though the package on anaconda says 11.3, the mac build is stuck at 9.0 and has been for a year. Does this mean no one has been able to set up SD locally on a Mac at all? I'm new to all this and that seems unlikely. There must be a workaround then that doesn't involve using CPU only?

vjandrei commented 1 year ago

Same issue here +1

arlequin-nyc commented 1 year ago

+1 same issue on a Mac M1 with anaconda.

rjwebb commented 1 year ago

According to the NVIDIA website, it looks like cudatoolkit is no longer supported on Mac:

NVIDIA® CUDA Toolkit 11.3 no longer supports development or running applications on macOS. While there are no tools which use macOS as a target environment, NVIDIA is making macOS host versions of these tools that you can launch profiling and debugging sessions on supported target platforms.

https://developer.nvidia.com/nvidia-cuda-toolkit-11_3_0-developer-tools-mac-hosts

kennethliukai commented 1 year ago

and the newest version of cudatoolkit for osx64 is 9.0 (check HERE). I tried to set "- cudatoolkit=9.0" in environment.yaml and got this error:

Traceback (most recent call last):
  File "scripts/txt2img.py", line 346, in <module>
    main()
  File "scripts/txt2img.py", line 242, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 65, in load_model_from_config
    model.cuda()
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 127, in cuda
    return super().cuda(device=device)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 601, in _apply
    param_applied = fn(param)
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/Users/rathinho/opt/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py", line 210, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

this patch will https://github.com/ModeratePrawn/stable-diffusion-cpu/pull/1/files run on CPU when GPU is not enabled. it will take approx an hour to generate results

So how to use these file : https://github.com/ModeratePrawn/stable-diffusion-cpu/pull/1/files? Replace some of the files in stable diffusion ? Thanks

vrunhofen commented 1 year ago

I assume this is related to PyTorch using Cuda. But there is now in PyTorch this: https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/

Which uses Apple's Metal APIs to work on GPU. I'm not sufficiently familiar with PyTorch or stable-diffusion to fix this issue myself. (Was just trying out stable-diffusion and couldn't set up the conda env like the OP).

If anyone has any suggestions or pointers, I'm happy to work on this. But I do need some starting guidance.

spencerkohan commented 1 year ago

Running into this issue as well. Is there any workaround?

adriaanbalt commented 1 year ago

cudatoolkit on mac is at version 9.0. Appears that the best method may be to try to deploy the environment to a remote server which has the correct hardware. Still learning though..

julianj commented 1 year ago

I just got past this issue doing the following:

  1. Install the latest version of cudatoolkit with conda install -c anaconda cudatoolkit
  2. Edit environment.yaml and replace cudatoolkit's version from 11.3 to the version just installed (mine was 9.0)
  3. Rerun conda env create -f environment.yaml and it should get to the end.
  4. Run conda activate ldm

I'm stuck now in the next step:

After obtaining the stable-diffusion-v1-*-original weights, link them

  • How/where do you obtain the weights?
  • In this command ln -s <path/to/model.ckpt> models/ldm/stable-diffusion-v1/model.ckpt where is path/to/model.ckpt or an example?
JetsomMa commented 1 year ago

https://github.com/CompVis/stable-diffusion/issues/309#issue-1381207452

Daemon-Devarshi commented 1 year ago

The solution suggested by @julianj did not work for me. Here is the result which I got after running conda install -c anaconda cudatoolkit:

Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

So I did the same as suggested above, got a lot of links to download it but all are failing and showing same message.

jsebdev commented 1 year ago

I just got past this issue doing the following:

  1. Install the latest version of cudatoolkit with conda install -c anaconda cudatoolkit
  2. Edit environment.yaml and replace cudatoolkit's version from 11.3 to the version just installed (mine was 9.0)
  3. Rerun conda env create -f environment.yaml and it should get to the end.
  4. Run conda activate ldm

I'm stuck now in the next step:

After obtaining the stable-diffusion-v1-*-original weights, link them

  • How/where do you obtain the weights?
  • In this command ln -s <path/to/model.ckpt> models/ldm/stable-diffusion-v1/model.ckpt where is path/to/model.ckpt or an example?

The weights can be found here: https://huggingface.co/CompVis

SeanWu089 commented 1 year ago

Got the same issue here with my 2019 Intel Mac Ventura 13.2.1. However, after several temptations of adjusting the codes, Conda in terminal asked me if I would downgrade a bunch of packages to download cudatoolkit ( not sure which version ). I typed y then the downloading succeeded, whereas it still showed the same error while creating an env for stable diffusion file.

截屏2023-03-07 22 27 33
alexchandel commented 1 year ago

Someone needs to port PyTorch's new macOS support to this project.

Ireneyhy commented 1 year ago

Same same M1 mac no cudatoolkit package (edited dependency to 9.0) -> package no longer supported for macOS -> STUCK

Thehardtimesofbeans commented 1 year ago

update mac system to the latest. I find,

howtomakeaturn commented 1 year ago

The solution provided by @julianj works for me.

My machine info is

MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)
1.4 GHz Quad-Core Intel Core i5
Intel Iris Plus Graphics 645 1536 MB

Now I'm trying to obtain the weights.

qyhdt commented 10 months ago

Got this error as well.

efalkenberg commented 6 months ago

5 months since the last post and it's still not possible to install stable diffusion locally on a mac?

ayeshaLS commented 6 months ago

Trying to use pytoch and cudatoolkit for Meta AudioCraft AI. Machine MacBook Pro , Chip Apple M1 Max. Same issue, no solution, thanks for posting this issue.