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

[Errno 2] No such file or directory: '\\kohya_ss\\venv\\Scripts\\accelerate.exe\\__main__.py' #38

Closed
SatyamSSJ10 opened this issue Jan 14, 2023 · 14 comments

Comments

@SatyamSSJ10
Copy link

SatyamSSJ10 commented Jan 14, 2023

C:\Users\satya\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in _run_module_as_main │
│ │
│ 193 │ main_globals = sys.modules["main"].dict
│ 194 │ if alter_argv: │
│ 195 │ │ sys.argv[0] = mod_spec.origin │
│ ❱ 196 │ return _run_code(code, main_globals, None, │
│ 197 │ │ │ │ │ "main", mod_spec) │
│ 198 │
│ 199 def run_module(mod_name, init_globals=None, │
│ C:\Users\satya\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code │
│ │
│ 83 │ │ │ │ │ loader = loader, │
│ 84 │ │ │ │ │ package = pkg_name, │
│ 85 │ │ │ │ │ spec = mod_spec) │
│ ❱ 86 │ exec(code, run_globals) │
│ 87 │ return run_globals │
│ 88 │
│ 89 def run_module_code(code, init_globals=None, │
│ │
│ G:\AI\kohya_ss\venv\Scripts\accelerate.exe_main
.py:7 in │
│ │
│ [Errno 2] No such file or directory: │
│ 'G:\AI\kohya_ss\venv\Scripts\accelerate.exe\main.py' │
│ │
│ G:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py:45 in main │
│ │
│ 42 │ │ exit(1) │
│ 43 │ │
│ 44 │ # Run │
│ ❱ 45 │ args.func(args) │
│ 46 │
│ 47 │
│ 48 if name == "main": │
│ │
│ G:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:1104 in launch_command │
│ │
│ 1101 │ elif defaults is not None and defaults.compute_environment == ComputeEnvironment.AMA │
│ 1102 │ │ sagemaker_launcher(defaults, args) │
│ 1103 │ else: │
│ ❱ 1104 │ │ simple_launcher(args) │
│ 1105 │
│ 1106 │
│ 1107 def main(): │
│ │
│ G:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:567 in simple_launcher │
│ │
│ 564 │ process = subprocess.Popen(cmd, env=current_env) │
│ 565 │ process.wait() │
│ 566 │ if process.returncode != 0: │
│ ❱ 567 │ │ raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) │
│ 568 │
│ 569 │
│ 570 def multi_gpu_launcher(args): │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CalledProcessError: Command '['G:\AI\kohya_ss\venv\Scripts\python.exe', './fine_tune.py', '--v2',
'--train_text_encoder', '--use_8bit_adam', '--xformers',
'--pretrained_model_name_or_path=G:/AI/stable-diffusion-webui/models/Stable-diffusion/animefull-final-pruned.ckpt',
'--in_json=G:/AI/stable-diffusion-webui/Train image/Yor - processed/meta_lat.json',
'--train_data_dir=G:/AI/stable-diffusion-webui/Train image/Yor - processed/10_YorForger',
'--output_dir=G:/AI/stable-diffusion-webui/Train image/Yor - processed/OUT',
'--logging_dir=G:/AI/stable-diffusion-webui/Train image/Yor - processed/LOG', '--train_batch_size=1',
'--dataset_repeats=40', '--learning_rate=1e-05', '--lr_scheduler=cosine', '--lr_warmup_steps=2320',
'--max_train_steps=11600', '--mixed_precision=fp16', '--save_every_n_epochs=1', '--seed=1234', '--save_precision=fp16',
'--output_name=last']' returned non-zero exit status 1.
Loading config...

@MrKuenning
Copy link

I also got this error

Doing standard LoRA training, both with 1.5 and 2.1 models.

ImportError: cannot import name 'CompVisVDenoiser' from 'k_diffusion.external'
(C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\site-packages\k_diffusion\external.py)

[Errno 2] No such file or directory:
'E:\AI\kohya_ss\venv\Scripts\accelerate.exe\main.py'

Console Output


│ E:\AI\kohya_ss\venv\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffu │
│ sion_k_diffusion.py:20 in <module>                                                               │
│                                                                                                  │
│    17                                                                                            │
│    18 import torch                                                                               │
│    19                                                                                            │
│ ❱  20 from k_diffusion.external import CompVisDenoiser, CompVisVDenoiser                         │
│    21                                                                                            │
│    22 from ... import DiffusionPipeline                                                          │
│    23 from ...schedulers import LMSDiscreteScheduler                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: cannot import name 'CompVisVDenoiser' from 'k_diffusion.external'
(C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\site-packages\k_diffusion\external.py)
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in _run_module_as_main   │
│                                                                                                  │
│   193 │   main_globals = sys.modules["__main__"].__dict__                                        │
│   194 │   if alter_argv:                                                                         │
│   195 │   │   sys.argv[0] = mod_spec.origin                                                      │
│ ❱ 196 │   return _run_code(code, main_globals, None,                                             │
│   197 │   │   │   │   │    "__main__", mod_spec)                                                 │
│   198                                                                                            │
│   199 def run_module(mod_name, init_globals=None,                                                │
│                                                                                                  │
│ C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code              │
│                                                                                                  │
│    83 │   │   │   │   │      __loader__ = loader,                                                │
│    84 │   │   │   │   │      __package__ = pkg_name,                                             │
│    85 │   │   │   │   │      __spec__ = mod_spec)                                                │
│ ❱  86 │   exec(code, run_globals)                                                                │
│    87 │   return run_globals                                                                     │
│    88                                                                                            │
│    89 def _run_module_code(code, init_globals=None,                                              │
│                                                                                                  │
│ E:\AI\kohya_ss\venv\Scripts\accelerate.exe\__main__.py:7 in <module>                             │
│                                                                                                  │
│ [Errno 2] No such file or directory:                                                             │
│ 'E:\\AI\\kohya_ss\\venv\\Scripts\\accelerate.exe\\__main__.py'                                │
│                                                                                                  │
│ E:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py:45 in main           │
│                                                                                                  │
│   42 │   │   exit(1)                                                                             │
│   43 │                                                                                           │
│   44 │   # Run                                                                                   │
│ ❱ 45 │   args.func(args)                                                                         │
│   46                                                                                             │
│   47                                                                                             │
│   48 if __name__ == "__main__":                                                                  │
│                                                                                                  │

@bmaltais
Copy link
Owner

This typically happen if you are installing modules outside the venv... or if you already have installed similar modules outside the venv.

This can be cause if you did not give unrestricted script access to powershell so venv can work:

  • Open an administrator powershell window
  • Type Set-ExecutionPolicy Unrestricted and answer A
  • Close admin powershell window

One quick fix is to uninstall everything from the local env and re-install everything in the venv:

Open a new powershell window and run:

pip freeze > uninstall.txt
pip uninstall -r uninstall.txt

Then redo the kohya_ss installation.

@MrKuenning
Copy link

MrKuenning commented Jan 19, 2023

That got me farther than before, but I still got an error...

Folder 100_charleshardman person: 1200 steps

Use DreamBooth method.
prepare train images.
found directory contains 12 image files
1200 train images with repeating.
loading image sizes.
100%|█████████████████████████████████| 12/12 [00:00<00:00, 1401.02it/s]
make buckets
number of images (including repeats)
bucket 8: resolution (512, 512), count: 1200
mean ar error (without repeats): 0.0
prepare accelerator
Using accelerator 0.15.0 or above.
load StableDiffusion checkpoint
loading u-net: <All keys matched successfully>
loading vae: <All keys matched successfully>
  File "E:\AI\kohya_ss\library\train_util.py", line 969, in replace_unet_cross_attn_to_xformers
    import xformers.ops

ModuleNotFoundError: No module named 'xformers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\AI\kohya_ss\train_network.py", line 424, in <module>
    train(args)
  File "E:\AI\kohya_ss\train_network.py", line 67, in train
    train_util.replace_unet_modules(unet, args.mem_eff_attn, args.xformers)
  File "E:\AI\kohya_ss\library\train_util.py", line 923, in replace_unet_modules
    replace_unet_cross_attn_to_xformers()
  File "E:\AI\kohya_ss\library\train_util.py", line 971, in replace_unet_cross_attn_to_xformers
    raise ImportError("No xformers / xformersがインストールされていないようです")
ImportError: No xformers / xformersがインストールされていないようです
Traceback (most recent call last):
  File "C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Brady\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "E:\AI\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 7, in <module>
  File "E:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main
    args.func(args)
  File "E:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command
    simple_launcher(args)
  File "E:\AI\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 567, in simple_launcher
    raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['E:\\AI\\kohya_ss\\venv\\Scripts\\python.exe', 'train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=E:/AI/Training/v1.5.ckpt', '--train_data_dir=E:\\AI\\Training\\aspen-4rd-512-Lora-Final\\img', '--resolution=512,512', '--output_dir=E:\\AI\\Training\\aspen-4rd-512-Lora-Final\\model', '--use_8bit_adam', '--xformers', '--logging_dir=E:\\AI\\Training\\aspen-4rd-512-Lora-Final\\log', '--network_module=networks.lora', '--text_encoder_lr=5e-5', '--unet_lr=1e-3', '--network_dim=8', '--output_name=last', '--learning_rate=1e-5', '--lr_scheduler=cosine', '--lr_warmup_steps=120', '--train_batch_size=1', '--max_train_steps=1200', '--save_every_n_epochs=1', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=1234', '--cache_latents', '--xformers', '--use_8bit_adam']' returned non-zero exit status 1.

@MrKuenning
Copy link

I resolved the above error by copying the xformers and xformers-0.0.14.dev0.dist-info folders from the venv folder in my Automatic1111 folder.

@SatyamSSJ10
Copy link
Author

This typically happen if you are installing modules outside the venv... or if you already have installed similar modules outside the venv.

This can be cause if you did not give unrestricted script access to powershell so venv can work:

* Open an administrator powershell window

* Type `Set-ExecutionPolicy Unrestricted` and answer A

* Close admin powershell window

One quick fix is to uninstall everything from the local env and re-install everything in the venv:

Open a new powershell window and run:

pip freeze > uninstall.txt
pip uninstall -r uninstall.txt

Then redo the kohya_ss installation.

is it really necessary to uninstall from the PC's environment? I honestly don't want to uninstall commonly used modules like torch

@SatyamSSJ10
Copy link
Author

I resolved the above error by copying the xformers and xformers-0.0.14.dev0.dist-info folders from the venv folder in my Automatic1111 folder.

did you uninstall from your local environment?

@SatyamSSJ10
Copy link
Author

This typically happen if you are installing modules outside the venv... or if you already have installed similar modules outside the venv.

This can be cause if you did not give unrestricted script access to powershell so venv can work:

* Open an administrator powershell window

* Type `Set-ExecutionPolicy Unrestricted` and answer A

* Close admin powershell window

One quick fix is to uninstall everything from the local env and re-install everything in the venv:

Open a new powershell window and run:

pip freeze > uninstall.txt
pip uninstall -r uninstall.txt

Then redo the kohya_ss installation.

Still facing the same.
I uninstalled using
pip uninstall -r requirements.txt

and then redid the setup

@MrKuenning
Copy link

Yes, I ran both uninstalls, the second one removed almost all of my AppData python files. It also took a while to say yes to almost 300 items.

I had tried many StableDiffusion reops in the past but almost exclusively use A1111 now, which also uses a VENV folder and not the AppData python folder. So it was kinda nice to remove all of that stuff anyway.

After I removed all of that I deleted the Kohya folder and reinstalled it. Re-running it threw a new error saying xformers was missing so I had to copy that from my a1111 install.

After that, it ran fine and made a decent first LoRA in about 15 minutes.

@bmaltais
Copy link
Owner

The error about xformer is puzzling... I will need to try a full re-install... perhaps the source URL for it has been removed... Let me test on my system

@bmaltais
Copy link
Owner

All went fine on my end. xformers installed fine also

@Odawgthat
Copy link

Odawgthat commented Feb 3, 2023

This typically happen if you are installing modules outside the venv... or if you already have installed similar modules outside the venv.

This can be cause if you did not give unrestricted script access to powershell so venv can work:

  • Open an administrator powershell window
  • Type Set-ExecutionPolicy Unrestricted and answer A
  • Close admin powershell window

One quick fix is to uninstall everything from the local env and re-install everything in the venv:

Open a new powershell window and run:

pip freeze > uninstall.txt
pip uninstall -r uninstall.txt

Then redo the kohya_ss installation.

DIDNT WORK! It still says that the folder venv/Scripts/accelerate doesn't exist?

@SatyamSSJ10
Copy link
Author

All went fine on my end. xformers installed fine also

I'm using Kohya's original sd scripts, and they did show these errors sometimes too, It was when RAM wasn't enough to load the stuff, and similar scenarios.

@Ho-gyo
Copy link

Ho-gyo commented Sep 30, 2023

Hi, please, could you provide an installer that work! I tried your suggestions but none worked for me.

@Stevoo01
Copy link

Stevoo01 commented Jun 16, 2024

In my case the folder sd-scripts where empty after I used get clone Kohya_ss, so I copy the content of the github folder in the one on my computer. It works afterwords without any problem.

sd_scripts looks a bit diffrent (in blue and with @bfb352b tagged) may the missing folder is related to this "link".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants