stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

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

Open ivandov opened this issue 2 years ago • 29 comments

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

  • Macbook Pro, AMD64, macOS 12.5.1
  • conda installed through homebrew with brew install --cask miniconda

ivandov avatar Sep 21 '22 16:09 ivandov

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

ssunday avatar Sep 22 '22 00:09 ssunday

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

rogersanick avatar Sep 22 '22 02:09 rogersanick

having this problem as well

rathinho avatar Sep 22 '22 07:09 rathinho

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

rathinho avatar Sep 22 '22 08:09 rathinho

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

kencanak avatar Sep 22 '22 11:09 kencanak

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..

rathinho avatar Sep 26 '22 04:09 rathinho

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

Merkwurdichliebe avatar Oct 06 '22 07:10 Merkwurdichliebe

+1

danielcaldas avatar Oct 08 '22 18:10 danielcaldas

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

haroldlbrown avatar Oct 12 '22 08:10 haroldlbrown

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?

mlynch avatar Oct 24 '22 13:10 mlynch

Same issue here +1

vjandrei avatar Nov 08 '22 10:11 vjandrei

+1 same issue on a Mac M1 with anaconda.

arlequin-nyc avatar Nov 11 '22 16:11 arlequin-nyc

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

rjwebb avatar Nov 13 '22 22:11 rjwebb

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

kennethliukai avatar Dec 12 '22 06:12 kennethliukai

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.

vrunhofen avatar Dec 28 '22 08:12 vrunhofen

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

spencerkohan avatar Jan 04 '23 05:01 spencerkohan

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..

adriaanbalt avatar Jan 06 '23 12:01 adriaanbalt

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?

julianj avatar Feb 01 '23 03:02 julianj

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

JetsomMa avatar Feb 08 '23 03:02 JetsomMa

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:

  • cudatoolkit

Current channels:

  • https://conda.anaconda.org/anaconda/osx-arm64
  • https://conda.anaconda.org/anaconda/noarch
  • https://conda.anaconda.org/pytorch/osx-arm64
  • https://conda.anaconda.org/pytorch/noarch
  • https://conda.anaconda.org/conda-forge/osx-arm64
  • https://conda.anaconda.org/conda-forge/noarch
  • https://repo.anaconda.com/pkgs/main/osx-arm64
  • https://repo.anaconda.com/pkgs/main/noarch
  • https://repo.anaconda.com/pkgs/r/osx-arm64
  • https://repo.anaconda.com/pkgs/r/noarch

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.

Daemon-Devarshi avatar Feb 15 '23 17:02 Daemon-Devarshi

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

jsebdev avatar Feb 18 '23 19:02 jsebdev

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

SeanWu089 avatar Mar 07 '23 14:03 SeanWu089

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

alexchandel avatar Mar 21 '23 02:03 alexchandel

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

Ireneyhy avatar May 26 '23 07:05 Ireneyhy

update mac system to the latest. I find,

Thehardtimesofbeans avatar May 29 '23 09:05 Thehardtimesofbeans

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.

howtomakeaturn avatar Aug 16 '23 08:08 howtomakeaturn

Got this error as well.

qyhdt avatar Dec 14 '23 08:12 qyhdt

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

efalkenberg avatar Apr 10 '24 02:04 efalkenberg

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.

ayeshaLS avatar Apr 16 '24 21:04 ayeshaLS