Mightys commited on
Commit
28c103f
verified
1 Parent(s): d195ab2

Update Forge Neo py-3.13 Kaggle/install_forge_neo.py

Browse files
Forge Neo py-3.13 Kaggle/install_forge_neo.py CHANGED
@@ -1,118 +1,119 @@
1
- #!/usr/bin/env python3
2
- """
3
- install_forge_neo.py
4
- Instala sd-webui-forge-classic (rama neo) en Kaggle con Python 3.13, SageAttention y enlaces temporales.
5
- """
6
-
7
- import os
8
- import subprocess
9
- from pathlib import Path
10
-
11
- WORK_DIR = Path("/kaggle/working").resolve()
12
- FORGE_DIR = WORK_DIR / "sd-webui-forge-classic"
13
- EXT_DIR = FORGE_DIR / "extensions"
14
-
15
- def _run(cmd: str, cwd: Path | None = None) -> None:
16
- """Ejecuta un comando shell."""
17
- print(f"+ {cmd}")
18
- subprocess.run(cmd, shell=True, check=False, cwd=cwd)
19
-
20
- def clone(repo: str, depth: int | None = None, cwd: Path | None = None) -> None:
21
- """Clona un repositorio git."""
22
- cmd = "git clone"
23
- if depth:
24
- cmd += f" --depth {depth}"
25
- cmd += f" {repo}"
26
- _run(cmd, cwd=cwd)
27
-
28
- def wget(url: str, output: str | None = None) -> None:
29
- """Descarga con wget."""
30
- cmd = "wget"
31
- if output:
32
- cmd += f" -O {output}"
33
- cmd += f" {url}"
34
- _run(cmd)
35
-
36
- def main() -> None:
37
- os.chdir(WORK_DIR)
38
-
39
- # 1. Descargas iniciales
40
- wget("https://huggingface.co/datasets/Mightys/Notebook_Scripts/resolve/main/libmimalloc.so.2.1")
41
- wget("https://huggingface.co/datasets/Mightys/SwarmuiColab/resolve/main/scripts/download_magic.py")
42
-
43
- # 2. Clonar forge-classic (rama neo)
44
- if not FORGE_DIR.exists():
45
- clone("https://github.com/Haoming02/sd-webui-forge-classic.git -b neo")
46
- else:
47
- _run("git pull", cwd=FORGE_DIR)
48
-
49
- # 3. Extensiones
50
- EXT_DIR.mkdir(parents=True, exist_ok=True)
51
-
52
- repos = [
53
- ("https://github.com/gutris1/sd-image-encryption", None),
54
- ("https://github.com/gutris1/sd-hub", 1),
55
- ("https://github.com/Haoming02/sd-forge-couple", 1),
56
- ("https://github.com/AlUlkesh/stable-diffusion-webui-images-browser", 1),
57
- ("https://github.com/DominikDoom/a1111-sd-webui-tagcomplete", 1),
58
- ("https://github.com/gutris1/sd-image-info", 1),
59
- ("https://github.com/viyiviyi/stable-diffusion-webui-zoomimage", 1),
60
- ("https://github.com/gutris1/sd-simple-dimension-preset", 1),
61
- ("https://github.com/gutris1/sd-civitai-browser-plus-plus", 1),
62
- ]
63
-
64
- for repo, depth in repos:
65
- clone(repo, depth=depth, cwd=EXT_DIR)
66
-
67
- # 4. Sistema + aria2 + gdown
68
- _run("sudo apt update -qq")
69
- _run("sudo apt install aria2 -q")
70
- _run("pip install gdown -q")
71
-
72
- # 5. Instalar uv
73
- _run("curl -LsSf https://astral.sh/uv/install.sh | sh")
74
-
75
- # 6. Python 3.13 y venv
76
- os.chdir(FORGE_DIR)
77
- _run("sudo apt install -y python3.13 python3.13-dev python3.13-venv build-essential")
78
- _run("curl -LsSf https://astral.sh/uv/install.sh | sh")
79
- _run("uv venv .venv --python /usr/bin/python3.13 --seed --clear")
80
- _run("/usr/bin/python3.13 -m ensurepip --upgrade")
81
- _run("/usr/bin/python3.13 -m pip install --upgrade pip setuptools wheel")
82
-
83
- # 7. SageAttention
84
- wheel = "sageattention-2.1.2-cp313-cp313-linux_x86_64.whl"
85
- wget(f"https://huggingface.co/datasets/WhiteAiZ/T4_SageAttention2_For_Google_Colab/resolve/main/{wheel}")
86
- _run(f"uv pip install --python /usr/bin/python3.13 {wheel}")
87
-
88
- # 8. Dependencias de Forge
89
- _run("uv pip install --python /usr/bin/python3.13 -r requirements.txt --no-progress")
90
- _run("uv pip install --python /usr/bin/python3.13 torch torchvision xformers triton==3.5.1 --index-url https://download.pytorch.org/whl/cu128 --no-progress")
91
-
92
- # 9. Enlaces temporales
93
- links = [
94
- "rm -rf /kaggle/working/tmp ~/tmp",
95
- "ln -vs /tmp ~/tmp",
96
- "rm -rf /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models",
97
- "mkdir -p /tmp/models",
98
- "ln -vs /tmp/models /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models",
99
- "rm -rf /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora",
100
- "mkdir -p /tmp/lora",
101
- "ln -vs /tmp/lora /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora",
102
- "rm -rf /kaggle/working/sd-webui-forge-classic/models/ControlNet",
103
- "mkdir -p /tmp/controlnet",
104
- "ln -vs /tmp/controlnet /kaggle/working/sd-webui-forge-classic/models/ControlNet",
105
- "rm -rf /kaggle/working/sd-webui-forge-classic/models/text_encoder",
106
- "mkdir -p /tmp/text_encoder",
107
- "ln -vs /tmp/text_encoder /kaggle/working/sd-webui-forge-classic/models/text_encoder",
108
- ]
109
- for cmd in links:
110
- _run(cmd)
111
-
112
- # 10. Mensaje final
113
- print("\n" + "=" * 50)
114
- print("馃帀 Instalaci贸n completada")
115
- print("=" * 50)
116
-
117
- if __name__ == "__main__":
 
118
  main()
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ install_forge_neo.py
4
+ Instala sd-webui-forge-classic (rama neo) en Kaggle con Python 3.13, SageAttention y enlaces temporales.
5
+ """
6
+
7
+ import os
8
+ import subprocess
9
+ from pathlib import Path
10
+
11
+ WORK_DIR = Path("/kaggle/working").resolve()
12
+ FORGE_DIR = WORK_DIR / "sd-webui-forge-classic"
13
+ EXT_DIR = FORGE_DIR / "extensions"
14
+
15
+ def _run(cmd: str, cwd: Path | None = None) -> None:
16
+ """Ejecuta un comando shell."""
17
+ print(f"+ {cmd}")
18
+ subprocess.run(cmd, shell=True, check=False, cwd=cwd)
19
+
20
+ def clone(repo: str, depth: int | None = None, cwd: Path | None = None) -> None:
21
+ """Clona un repositorio git."""
22
+ cmd = "git clone"
23
+ if depth:
24
+ cmd += f" --depth {depth}"
25
+ cmd += f" {repo}"
26
+ _run(cmd, cwd=cwd)
27
+
28
+ def wget(url: str, output: str | None = None) -> None:
29
+ """Descarga con wget."""
30
+ cmd = "wget"
31
+ if output:
32
+ cmd += f" -O {output}"
33
+ cmd += f" {url}"
34
+ _run(cmd)
35
+
36
+ def main() -> None:
37
+ os.chdir(WORK_DIR)
38
+
39
+ # 1. Descargas iniciales
40
+ wget("https://huggingface.co/datasets/Mightys/Notebook_Scripts/resolve/main/libmimalloc.so.2.1")
41
+ wget("https://huggingface.co/datasets/Mightys/SwarmuiColab/resolve/main/scripts/download_magic.py")
42
+
43
+ # 2. Clonar forge-classic (rama neo)
44
+ if not FORGE_DIR.exists():
45
+ clone("https://github.com/Haoming02/sd-webui-forge-classic.git -b neo")
46
+ else:
47
+ _run("git pull", cwd=FORGE_DIR)
48
+
49
+ # 3. Extensiones
50
+ EXT_DIR.mkdir(parents=True, exist_ok=True)
51
+
52
+ repos = [
53
+ ("https://github.com/gutris1/sd-image-encryption", None),
54
+ ("https://github.com/gutris1/sd-hub", 1),
55
+ ("https://github.com/Haoming02/sd-forge-couple", 1),
56
+ ("https://github.com/AlUlkesh/stable-diffusion-webui-images-browser", 1),
57
+ ("https://github.com/DominikDoom/a1111-sd-webui-tagcomplete", 1),
58
+ ("https://github.com/gutris1/sd-image-info", 1),
59
+ ("https://github.com/viyiviyi/stable-diffusion-webui-zoomimage", 1),
60
+ ("https://github.com/gutris1/sd-simple-dimension-preset", 1),
61
+ ("https://github.com/Bing-su/adetailer", 1),
62
+ ("https://github.com/gutris1/sd-civitai-browser-plus-plus", 1),
63
+ ]
64
+
65
+ for repo, depth in repos:
66
+ clone(repo, depth=depth, cwd=EXT_DIR)
67
+
68
+ # 4. Sistema + aria2 + gdown
69
+ _run("sudo apt update -qq")
70
+ _run("sudo apt install aria2 -q")
71
+ _run("pip install gdown -q")
72
+
73
+ # 5. Instalar uv
74
+ _run("curl -LsSf https://astral.sh/uv/install.sh | sh")
75
+
76
+ # 6. Python 3.13 y venv
77
+ os.chdir(FORGE_DIR)
78
+ _run("sudo apt install -y python3.13 python3.13-dev python3.13-venv build-essential")
79
+ _run("curl -LsSf https://astral.sh/uv/install.sh | sh")
80
+ _run("uv venv .venv --python /usr/bin/python3.13 --seed --clear")
81
+ _run("/usr/bin/python3.13 -m ensurepip --upgrade")
82
+ _run("/usr/bin/python3.13 -m pip install --upgrade pip setuptools wheel")
83
+
84
+ # 7. SageAttention
85
+ wheel = "sageattention-2.1.2-cp313-cp313-linux_x86_64.whl"
86
+ wget(f"https://huggingface.co/datasets/WhiteAiZ/T4_SageAttention2_For_Google_Colab/resolve/main/{wheel}")
87
+ _run(f"uv pip install --python /usr/bin/python3.13 {wheel}")
88
+
89
+ # 8. Dependencias de Forge
90
+ _run("uv pip install --python /usr/bin/python3.13 -r requirements.txt --no-progress")
91
+ _run("uv pip install --python /usr/bin/python3.13 torch torchvision xformers triton==3.5.1 --index-url https://download.pytorch.org/whl/cu128 --no-progress")
92
+
93
+ # 9. Enlaces temporales
94
+ links = [
95
+ "rm -rf /kaggle/working/tmp ~/tmp",
96
+ "ln -vs /tmp ~/tmp",
97
+ "rm -rf /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models",
98
+ "mkdir -p /tmp/models",
99
+ "ln -vs /tmp/models /kaggle/working/sd-webui-forge-classic/models/Stable-diffusion/tmp_models",
100
+ "rm -rf /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora",
101
+ "mkdir -p /tmp/lora",
102
+ "ln -vs /tmp/lora /kaggle/working/sd-webui-forge-classic/models/Lora/tmp_lora",
103
+ "rm -rf /kaggle/working/sd-webui-forge-classic/models/ControlNet",
104
+ "mkdir -p /tmp/controlnet",
105
+ "ln -vs /tmp/controlnet /kaggle/working/sd-webui-forge-classic/models/ControlNet",
106
+ "rm -rf /kaggle/working/sd-webui-forge-classic/models/text_encoder",
107
+ "mkdir -p /tmp/text_encoder",
108
+ "ln -vs /tmp/text_encoder /kaggle/working/sd-webui-forge-classic/models/text_encoder",
109
+ ]
110
+ for cmd in links:
111
+ _run(cmd)
112
+
113
+ # 10. Mensaje final
114
+ print("\n" + "=" * 50)
115
+ print("馃帀 Instalaci贸n completada")
116
+ print("=" * 50)
117
+
118
+ if __name__ == "__main__":
119
  main()