InvokeAI
InvokeAI copied to clipboard
[bug]: Error GPU Mac M1 when training Stable Diffusion using Textual Inversion
Is there an existing issue for this?
- [X] I have searched the existing issues
OS
macOS
GPU
mps
VRAM
16
What happened?
I have a problem when I re-implement it. I run it on Mac pro M1, and I have error: "RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (CPU) " when I training with command:
python main.py --base ./configs/stable-diffusion/v1-finetune.yaml
-t
--actual_resume ./models/ldm/stable-diffusion-v1/model.ckpt
-n my_key
--gpus 0,
--data_root ./training_data/key/
So, Can you help me fix this error, please? Thank you very much! My laptop is Macbook Pro 14" M1pro
Screenshots


Additional context
No response
Contact Details
fix for this: https://github.com/Birch-san/stable-diffusion/commit/46f793b5ecd5bdd70ee8c9da9c6f379aa566afc5 also, if you are using a nightly build of pytorch, you might face some bugs
fix for this: Birch-san/stable-diffusion@46f793b also, if you are using a nightly build of pytorch, you might face some bugs
Thank you very much! I'll try this
Thanks @remixer-dec for pointing to the solution. I’ll apply it to InvokeAI.
Im still getting the same error, any idea what I should be doing differently?
@pangshengwei Try this command:
python main.py --base ./configs/stable-diffusion/v1-finetune.yaml
-t
--actual_resume ./models/ldm/stable-diffusion-v1/model.ckpt
-n my_key
--accelarator "cpu"
--data_root ./training_data/key/
use --accelarator "cpu"
, or --accelarator "mps"
, not --gpus 0
@FreeBlues for M1 chips there is a config called v1-m1-finetune.yaml
@remixer-dec Thank you, I will have a try.
I was getting this error on an M1 mac while attempting textual inversion...
MisconfigurationException: MPSAccelerator can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into
accelerator
argument ofTrainer
: ['cpu'].
I went down a rabbithole of attempting various version changes, nightlies, updates, etc - nothing worked.
I finally realized that despite actually being on an M1, and having built python and conda and so on with the arm64
appropriate invocations ... there is some code that determines while running, what platform it's running on.
When I would run things like uname
and uname -m
and arch
and so on, I was getting answers in the x86_64
and i386
and such. I eventually realized that because I was running a zsh which was installed through intel homebrew (probably from migrating previous laptop onto this newer M1 device), that was cascading down.
I was able to install both the M1-specific version of homebrew, and then separately reinstall zsh with that homebrew ... and now I get arm64
from arch
command and arm64
from uname -m
as well.
...I'm not sure if this is the end of my issues or not, but it at least got me past the error I was seeing and the inversion script is running now. Hope this helps someone else!
I was getting this error on an M1 mac while attempting textual inversion...
MisconfigurationException: MPSAccelerator can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into
accelerator
argument ofTrainer
: ['cpu'].I went down a rabbithole of attempting various version changes, nightlies, updates, etc - nothing worked.
I finally realized that despite actually being on an M1, and having built python and conda and so on with the
arm64
appropriate invocations ... there is some code that determines while running, what platform it's running on.When I would run things like
uname
anduname -m
andarch
and so on, I was getting answers in thex86_64
andi386
and such. I eventually realized that because I was running a zsh which was installed through intel homebrew (probably from migrating previous laptop onto this newer M1 device), that was cascading down.I was able to install both the M1-specific version of homebrew, and then separately reinstall zsh with that homebrew ... and now I get
arm64
fromarch
command andarm64
fromuname -m
as well....I'm not sure if this is the end of my issues or not, but it at least got me past the error I was seeing and the inversion script is running now. Hope this helps someone else!
@mjankowski Do you have a link to installing the M1-specific version of homebrew?
Trying to train Textual Inversion on my M1 Mac and getting no where.
You just reinstall it and it will install the M1 version when it pulls down from the repo. This blog post was useful - https://earthly.dev/blog/homebrew-on-m1/ as were random notes in the homebrew repo.
You might have to supply something like arch -arm64 /bin/bash -c "$(curl ..."
during the install so that it selects properly, if its attempting to reinstall the intel versions.
Notably - homebrew switched to keeping things in /opt/homebrew
for the m1 version ... so unrelated to anything to do with GPUs or inversion, you'll have to manage that.