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

Error: Instalation AI Krita, on a Mac Pro 2009, OS Montery, GPU Raedon VII #528

Closed
Sauerblume opened this issue Mar 26, 2024 · 10 comments
Closed
Labels
mac-os Apple macOS related

Comments

@Sauerblume
Copy link

Error: Could not find a version that satisfies the requirement torch ( from version none) Error: No matching distribution found for torch

@Acly Acly added the mac-os Apple macOS related label Mar 28, 2024
@Acly
Copy link
Owner

Acly commented Mar 28, 2024

Maybe not a supported Python version? Check client.log to see which version it is using.

@mamecoder
Copy link

I'm experiencing a similar issue in the Mac environment. I can't seem to get rid of the error.

Error:

Error: Error during installation: ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

PyTorch cannot be installed.

My environment is as follows:

macOS Monterey 12.74 M1 MAX (updated from 12.3)
Python versions tried: 3.8, 3.11, 3.10.7 (currently using 3.10.7)
krita-ai-diffusion versions tried:Version 1.14.1, Version 1.15.0, Version 1.16.0

Similar errors occurred with all versions. Error log:

2024-03-31 19:18:30,906 INFO Extension initialized, Version: 1.16.0, Python: 3.10.7 (main, Dec  7 2023, 11:44:20) [Clang 13.0.0 (clang-1300.0.29.30)]
2024-03-31 19:18:31,836 INFO Connecting to http://127.0.0.1:8188
2024-03-31 19:20:27,215 INFO Installation started in /Users/xxx/Library/Application Support/krita/ai_diffusion/server
2024-03-31 19:20:27,218 INFO Creating venv in /Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv
2024-03-31 19:20:27,219 INFO Executing /usr/bin/python3 -m venv venv
2024-03-31 19:20:29,889 INFO Using Python: Python 3.8.9, /Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv/bin/python3
2024-03-31 19:20:30,188 INFO Using pip: pip 20.2.3 from /Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv/lib/python3.8/site-packages/pip (python 3.8)
2024-03-31 19:20:30,188 INFO Downloading https://github.com/comfyanonymous/ComfyUI/archive/40e124c6be01195eada95e8c319ca6ddf4fd1a17.zip to /Users/xxx/Library/Application Support/krita/ai_diffusion/server/.cache/ComfyUI-40e124c6be01195eada95e8c319ca6ddf4fd1a17.zip
2024-03-31 19:20:31,622 INFO Extracting /Users/xxx/Library/Application Support/krita/ai_diffusion/server/.cache/ComfyUI-40e124c6be01195eada95e8c319ca6ddf4fd1a17.zip to /Users/xxx/Library/Application Support/krita/ai_diffusion/server
2024-03-31 19:20:31,707 INFO Executing /Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv/bin/python3 -su -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
2024-03-31 19:20:31,978 INFO Looking in indexes: https://download.pytorch.org/whl/cpu
2024-03-31 19:20:35,779 ERROR Error during installation: ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch
Traceback (most recent call last):
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 264, in install
    await self._install(cb)
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 139, in _install
    await try_install(comfy_dir, self._install_comfy, comfy_dir, network, cb)
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 559, in try_install
    raise e
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 554, in try_install
    await installer(*args)
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 193, in _install_comfy
    await _execute_process("PyTorch", self._pip_install(*torch_args), self.path, cb)
  File "/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server.py", line 548, in _execute_process
    raise Exception(f"Error during installation: {errlog}")
Exception: Error during installation: ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch

2024-03-31 19:20:35,780 ERROR Installation failed

I'm installing krita-ai-diffusion in the default folder:
/Users/xxx/Library/Application Support/krita/ai_diffusion/server

However, some users seem to be installing it in the following location:
/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server
Is this relevant to the issue?

If this issue cannot be resolved, is there a way to manually install PyTorch instead of relying on the automatic installation?

I'm looking forward to using krita-ai-diffusion. Any advice on getting it to work would be greatly appreciated.

@Acly
Copy link
Owner

Acly commented Mar 31, 2024

2024-03-31 19:20:27,219 INFO Executing /usr/bin/python3 -m venv venv
2024-03-31 19:20:29,889 INFO Using Python: Python 3.8.9, /Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv/bin/python

This is an issue. It seems python3 on your system maps to Python 3.8.9, which is too old. The installer tries python3.11, python3.10, python3 commands in that order, so it seems like it couldn't find a newer version, and the default is 3.8

I'm not sure how you change that on Mac though.

However, some users seem to be installing it in the following location:
/Users/xxx/Library/Application Support/krita/pykrita/ai_diffusion/server
Is this relevant to the issue?

No, prefer the new location not inside the plugin folder, makes updates easier (or you can choose any other path to install in)

@mamecoder
Copy link

Thank you very much for your help. I now understand the issue with the installation folder.

I thought I was using Python 3.10.6, but I realized that Python 3.8 was actually being used. When I check in the terminal, it shows 3.10.6. (Sorry, I made a mistake, it's 3.10.6, not 3.10.7)

MBP ~ % python3 --version
Python 3.10.6

I understood that the cause was the installer using a different Python environment. Originally, the pre-installed Python on my Mac was 3.8. For krita-ai-diffusion, I tried installing Python 3.11, but it didn't work, so I additionally installed Python 3.10. However, it seems that it wasn't being referenced.

I have never used Python before, so I don't understand it well. However, I tried rewriting server.py as follows. _find_program couldn't find the correct Python.

import sys

if sys.platform == "darwin": # macOS
    self._python_cmd = Path("/usr/local/bin/python3.10")
elif sys.platform == "win32": # Windows
    self._python_cmd = Path("C:Python310python.exe")
else: # Linux and others
    self._python_cmd = Path("/usr/bin/python3.10")

if self._python_cmd is None:
    raise Exception("Python not found. Please install Python 3.10 and try again.")

# if python_path is None:
#     self._python_cmd = _find_program("python3.11", "python3.10", "python3", "python")
#     self._python_cmd = _find_program("python3.10")
# else:
#     self._python_cmd = python_path / f"python{_exe}"

By doing this, I was able to start the installation. The additional Python seems to be installed in /usr/local/bin/. However, the pre-installed Python doesn't seem to be in this folder.

The installation proceeded smoothly up to a point, but then the following error occurred.

Error: Error during server startup: ModuleNotFoundError: No module named 'safetensors' [1]

Manually installing this won't fundamentally solve the problem, right?

pip install safetensors

Would it be possible to add the safetensors module to the dependencies?

@Acly
Copy link
Owner

Acly commented Mar 31, 2024

Sounds like what happened might be that you started installation the first time with Python 3.8 as default python3. The first thing the installer does is create a "venv" (virtual environment), a separate place to store copies/links of all modules in order to not mess up your system Python. It's located in .../krita/ai_diffusion/server/venv

At this point, if you retry the installer without deleting the venv, it will continue to use it instead of restarting from scratch. So installing additional Python versions has no effect at this point.

Would it be possible to add the safetensors module to the dependencies?

It already is. but maybe it was installed into the venv before the error occured, and now you're using a different environment.

Anyway, it would be interesting if it picks up the correct Python and works without modifications, when you install into an empty (or non existing) folder. That's assuming you didn't already try that, then it must be something else...

@mamecoder
Copy link

Thank you for your reply.

I tried deleting ai_diffusion and reinstalling it from the beginning. However, I encountered the same error.

Error during server startup: ModuleNotFoundError: No module named 'safetensors' [1]

The safetensors module was indeed installed.

xxx@xxxnoMBP ~ % source "/Users/xxx/Library/Application Support/krita/ai_diffusion/server/venv/bin/activate"
(venv) xxx@xxxnoMBP ~ % pip install safetensors
Requirement already satisfied: safetensors in ./Library/Application Support/krita/ai_diffusion/server/venv/lib/python3.10/site-packages (0.4.2)

[notice] A new release of pip available: 22.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip

The installation log also shows:

2024-04-01 18:06:40,385 INFO Collecting safetensors>=0.3.0
2024-04-01 18:06:40,385 INFO Using cached safetensors-0.4.2-cp310-cp310-macosx_11_0_arm64.whl (393 kB)

However, I still get an error.

2024-04-01 19:46:32,915 INFO Found server installation v1.16.0 at /Users/xxx/Library/Application Support/krita/ai_diffusion/server
2024-04-01 19:46:33,879 INFO Starting server with python -su -Xutf8 main.py
2024-04-01 19:46:34,982 WARNING Failed to launch/connect server at startup: Error during server startup: ModuleNotFoundError: No module named 'safetensors' [1]

Why is there an error even though safetensors is installed?

The result of pip list is provided below.

ip list
Package                   Version
------------------------- ------------------
absl-py                   2.1.0
addict                    2.4.0
aiohttp                   3.9.3
aiosignal                 1.3.1
albumentations            1.4.2
antlr4-python3-runtime    4.9.3
async-timeout             4.0.3
attrs                     23.2.0
certifi                   2024.2.2
cffi                      1.16.0
chardet                   5.2.0
charset-normalizer        3.3.2
colorlog                  6.8.2
contourpy                 1.2.0
cssselect2                0.7.0
cycler                    0.12.1
einops                    0.7.0
filelock                  3.9.0
flatbuffers               24.3.25
fonttools                 4.50.0
frozenlist                1.4.1
fsspec                    2024.3.1
ftfy                      6.2.0
fvcore                    0.1.5.post20221221
huggingface-hub           0.22.2
idna                      3.6
imageio                   2.34.0
importlib_metadata        7.1.0
iopath                    0.1.10
jax                       0.4.25
jaxlib                    0.4.25
Jinja2                    3.1.2
joblib                    1.3.2
jsonschema                4.21.1
jsonschema-specifications 2023.12.1
kiwisolver                1.4.5
kornia                    0.7.2
kornia_rs                 0.1.2
lazy_loader               0.3
lxml                      5.2.0
mapbox-earcut             1.0.1
MarkupSafe                2.1.3
matplotlib                3.8.3
mediapipe                 0.10.11
ml-dtypes                 0.3.2
mpmath                    1.3.0
multidict                 6.0.5
networkx                  3.2.1
numpy                     1.26.3
omegaconf                 2.3.0
opencv-contrib-python     4.9.0.80
opencv-python             4.9.0.80
opencv-python-headless    4.9.0.80
opt-einsum                3.3.0
packaging                 24.0
pillow                    10.2.0
pip                       24.0
platformdirs              4.2.0
portalocker               2.8.2
protobuf                  3.20.3
psutil                    5.9.8
pycollada                 0.8
pycparser                 2.22
pyparsing                 3.1.2
python-dateutil           2.9.0.post0
PyYAML                    6.0.1
referencing               0.34.0
regex                     2023.12.25
reportlab                 4.1.0
requests                  2.31.0
rpds-py                   0.18.0
Rtree                     1.2.0
safetensors               0.4.2
scikit-image              0.22.0
scikit-learn              1.4.1.post1
scipy                     1.12.0
setuptools                63.2.0
shapely                   2.0.3
six                       1.16.0
sounddevice               0.4.6
svg.path                  6.3
svglib                    1.5.1
sympy                     1.12
tabulate                  0.9.0
termcolor                 2.4.0
threadpoolctl             3.4.0
tifffile                  2024.2.12
tinycss2                  1.2.1
tokenizers                0.15.2
tomli                     2.0.1
torch                     2.2.2
torchaudio                2.2.2
torchsde                  0.2.6
torchvision               0.17.2
tqdm                      4.66.2
trampoline                0.1.2
transformers              4.39.2
trimesh                   3.21.7
typing_extensions         4.10.0
urllib3                   2.2.1
wcwidth                   0.2.13
webencodings              0.5.1
xxhash                    3.4.1
yacs                      0.1.8
yapf                      0.40.2
yarl                      1.9.4
zipp                      3.18.1

The installation seems to have completed successfully, but is there anything missing?

I'm not sure how to solve this issue. I would appreciate any suggestions for improvement.

@Acly
Copy link
Owner

Acly commented Apr 2, 2024

It's strange. Can you try running ComfyUI from console directly?
Activate the venv as before. Run with

python /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/main.py

Does it run into the same error? print anything else?

@mamecoder
Copy link

mamecoder commented Apr 2, 2024

Thanks for your reply.
I tested it and it seems to have started up.

(venv) xxx@xxxnoMBP ~ % python "/Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/main.py"

Total VRAM 32768 MB, total RAM 32768 MB

Set vram state to: SHARED

Device: mps

VAE dtype: torch.float32

Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention

****** User settings have been changed to be stored on the server instead of browser storage. ******

****** For multi-user setups add the --multi-user CLI argument to enable multiple user profiles. ******

[comfyui_controlnet_aux] | INFO -> Using ckpts path: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/comfyui_controlnet_aux/ckpts

[comfyui_controlnet_aux] | INFO -> Using symlinks: False

[comfyui_controlnet_aux] | INFO -> Using ort providers: ['CUDAExecutionProvider', 'DirectMLExecutionProvider', 'OpenVINOExecutionProvider', 'ROCMExecutionProvider', 'CPUExecutionProvider', 'CoreMLExecutionProvider']

Failed to extract font properties from /System/Library/Fonts/Supplemental/NISC18030.ttf: In FT2Font: Could not set the fontsize (invalid pixel size; error code 0x17)

Failed to extract font properties from /System/Library/Fonts/Apple Color Emoji.ttc: In FT2Font: Could not set the fontsize (invalid pixel size; error code 0x17)

Failed to extract font properties from /System/Library/Fonts/LastResort.otf: tuple indices must be integers or slices, not str

generated new fontManager

/Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/comfyui_controlnet_aux/node_wrappers/dwpose.py:26: UserWarning: DWPose: Onnxruntime not found or doesn't come with acceleration providers, switch to OpenCV with CPU device. DWPose might run very slowly

warnings.warn("DWPose: Onnxruntime not found or doesn't come with acceleration providers, switch to OpenCV with CPU device. DWPose might run very slowly")

Import times for custom nodes:

0.0 seconds: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/comfyui-tooling-nodes

0.0 seconds: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/comfyui-inpaint-nodes

0.0 seconds: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus

0.1 seconds: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale

17.1 seconds: /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/custom_nodes/comfyui_controlnet_aux

Starting server

To see the GUI go to: http://127.0.0.1:8188

However, I cannot start krita-ai-diffusion.

Server is not installed or not running

When I press the Configure button, an error is displayed.

Error: Error during server startup: ModuleNotFoundError: No module named 'safetensors' [1]

@Acly
Copy link
Owner

Acly commented Apr 2, 2024

You should be able to use the "Custom server (local or remote)" option now and connect.

I don't understand either why it works manually, but not from the plugin...

Maybe it makes a difference if it's start with -su, could you try

python -su /Users/xxx/Library/Application Support/krita/ai_diffusion/server/ComfyUI/main.py

@mamecoder
Copy link

Thanks for your advice.

I managed to connect successfully using the Custom server (local or remote) option.

I didn't quite understand the difference between this and the -su option.

The menu appeared, but I couldn't generate images.

When I tried to generate an image, Python crashed with an unexpected error.

Also, when I attempted live drawing, I encountered the following error:
Server execution error: "upsample_nearest2d_channels_last" not implemented for 'Half'

I found this article:
#219

I took the plunge and updated from Monterey to Sonoma.

The Krita-AI-Diffusion plugin was grayed out, but after replacing the PyKrita data, I was able to use Krita-AI-Diffusion again.

On Sonoma, I can use the Local Managed Server without any errors.

Krita-AI-Diffusion is truly amazing.

Thank you!

@Acly Acly closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mac-os Apple macOS related
Projects
None yet
Development

No branches or pull requests

3 participants