Skip to content
Python

improved linux support'

DeepBeepMeepfac180426f9a
diff --git a/README.md b/README.md
index 4f38e15..9707afc 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models
-----
## 🔥 Latest Updates :
-### November 11 2025: WanGP v9.42, Free Lunch
+### November 12 2025: WanGP v9.43, Free Lunch
**VAE Upsampler** for Wan 2.1/2.2 Text 2 Image and Qwen Image: *spacepxl* has tweaked the VAE Decoder used by *Wan* & *Qwen* so that it can decode and upsample x2 at the same time. The end Result is a Fast High Quality Image Upsampler (much better than Lanczos). Check the *Postprocessing Tab* / *Spatial Upsampling* Dropdown box. Unfortunately this will work only with Image Generation, no support yet for Video Generation. I have also added a VAE Refiner that keeps the existing resolution but slightly improves the details.
@@ -48,6 +48,7 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models
*update 9.41*: Added Mocha & Lucy Edit 1.1\
*update 9.42*: Added Ovi 1.1
+*update 9.43*: Improved Linux support: no more visual artifacts with fp8 finetunes, auto install ffmpeg, detect audio device, ...
### November 6 2025: WanGP v9.35, How many bananas are too many bananas ?
@@ -181,7 +182,9 @@ See full changelog: **[Changelog](docs/CHANGELOG.md)**
## 🚀 Quick Start
**One-click installation:**
-- Get started instantly with [Pinokio App](https://pinokio.computer/)
+- Get started instantly with [Pinokio App](https://pinokio.computer/)\
+It is recommended to use in Pinokio the Community Scripts *wan2gp* or *wan2gp-amd* by **Morpheus** rather than the official Pinokio install.
+
- Use Redtash1 [One Click Install with Sage](https://github.com/Redtash1/Wan2GP-Windows-One-Click-Install-With-Sage)
**Manual installation:**
diff --git a/profiles/flux/Turbo Alpha 10 Steps.json b/profiles/flux/Turbo Alpha 10 Steps.json
index 4a93412..be1f5e1 100644
--- a/profiles/flux/Turbo Alpha 10 Steps.json
+++ b/profiles/flux/Turbo Alpha 10 Steps.json
@@ -3,6 +3,5 @@
"https://huggingface.co/DeepBeepMeep/Flux/resolve/main/loras_accelerators/FLUX.1-Turbo-Alpha.safetensors"
],
"loras_multipliers": "1",
- "num_inference_steps": 10,
- "guidance_scale": 1
-}
+ "num_inference_steps": 10
+}
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 3036275..cbc9d4e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -52,7 +52,7 @@ pydantic==2.10.6
# Math & modeling
torchdiffeq>=0.2.5
tensordict>=0.6.1
-mmgp==3.6.7
+mmgp==3.6.8
peft==0.15.0
matplotlib
diff --git a/shared/ffmpeg_setup.py b/shared/ffmpeg_setup.py
new file mode 100644
index 0000000..f042645
--- /dev/null
+++ b/shared/ffmpeg_setup.py
@@ -0,0 +1,210 @@
+import os
+import sys
+import shutil
+import tarfile
+import tempfile
+import typing
+from pathlib import Path
+
+import requests
+from tqdm import tqdm
+import zipfile
+
+
+__all__ = ["download_ffmpeg"]
+
+
+def download_ffmpeg(bin_directory: typing.Optional[typing.Union[str, Path]] = None):
+ """Ensure ffmpeg/ffprobe binaries (and their shared libs) are downloaded and on PATH."""
+ required_binaries = ["ffmpeg", "ffprobe"]
+ if os.name == "nt":
+ required_binaries.append("ffplay")
+
+ if bin_directory is None:
+ repo_root = Path(__file__).resolve().parents[1]
+ bin_dir = repo_root / "ffmpeg_bins"
+ else:
+ bin_dir = Path(bin_directory)
+
+ bin_dir.mkdir(parents=True, exist_ok=True)
+
+ def _ensure_bin_dir_on_path():
+ current_path = os.environ.get("PATH", "")
+ path_parts = current_path.split(os.pathsep) if current_path else []
+ if str(bin_dir) not in path_parts:
+ os.environ["PATH"] = os.pathsep.join([str(bin_dir)] + path_parts) if current_path else str(bin_dir)
+
+ def _ensure_library_path():
+ if os.name == "nt":
+ return
+ current_ld = os.environ.get("LD_LIBRARY_PATH", "")
+ ld_parts = [p for p in current_ld.split(os.pathsep) if p]
+ if str(bin_dir) not in ld_parts:
+ os.environ["LD_LIBRARY_PATH"] = os.pathsep.join([str(bin_dir)] + ld_parts) if current_ld else str(bin_dir)
+
+ _ensure_bin_dir_on_path()
+ _ensure_library_path()
+
+ def _candidate_name(name: str) -> str:
+ if os.name == "nt" and not name.endswith(".exe"):
+ return f"{name}.exe"
+ return name
+
+ def _resolve_path(name: str) -> typing.Optional[Path]:
+ candidate = bin_dir / _candidate_name(name)
+ if candidate.exists():
+ return candidate
+ resolved = shutil.which(name)
+ return Path(resolved) if resolved else None
+
+ def _binary_exists(name: str) -> bool:
+ return _resolve_path(name) is not None
+
+ def _libs_present() -> bool:
+ if os.name == "nt":
+ return True
+ return any(bin_dir.glob("libavdevice.so*"))
+
+ def _set_env_vars():
+ ffmpeg_path = _resolve_path("ffmpeg")
+ ffprobe_path = _resolve_path("ffprobe")
+ ffplay_path = _resolve_path("ffplay") if "ffplay" in required_binaries else None
+ if ffmpeg_path:
+ os.environ["FFMPEG_BINARY"] = str(ffmpeg_path)
+ if ffprobe_path:
+ os.environ["FFPROBE_BINARY"] = str(ffprobe_path)
+ if ffplay_path:
+ os.environ["FFPLAY_BINARY"] = str(ffplay_path)
+
+ missing = [binary for binary in required_binaries if not _binary_exists(binary)]
+ libs_ok = _libs_present()
+ if not missing and libs_ok:
+ _set_env_vars()
+ return
+
+ def _download_file(url: str, destination: Path):
+ with requests.get(url, stream=True, timeout=120) as response:
+ response.raise_for_status()
+ total = int(response.headers.get("Content-Length", 0))
+ with open(destination, "wb") as file_handle, tqdm(
+ total=total if total else None,
+ unit="B",
+ unit_scale=True,
+ desc=f"Downloading {destination.name}"
+ ) as progress:
+ for chunk in response.iter_content(chunk_size=8192):
+ if not chunk:
+ continue
+ file_handle.write(chunk)
+ progress.update(len(chunk))
+
+ def _download_windows_build():
+ exes = [_candidate_name(name) for name in required_binaries]
+ api_url = "https://api.github.com/repos/GyanD/codexffmpeg/releases/latest"
+ response = requests.get(api_url, headers={"Accept": "application/vnd.github+json"}, timeout=30)
+ response.raise_for_status()
+ assets = response.json().get("assets", [])
+ zip_asset = next((asset for asset in assets if asset.get("name", "").endswith("essentials_build.zip")), None)
+ if not zip_asset:
+ raise RuntimeError("Unable to locate FFmpeg essentials build for Windows.")
+ zip_path = bin_dir / zip_asset["name"]
+ _download_file(zip_asset["browser_download_url"], zip_path)
+
+ try:
+ with zipfile.ZipFile(zip_path) as archive:
+ for member in archive.namelist():
+ normalized = member.replace("\\", "/")
+ if "/bin/" not in normalized:
+ continue
+ base_name = os.path.basename(normalized)
+ if base_name not in exes and not base_name.lower().endswith(".dll"):
+ continue
+ destination = bin_dir / base_name
+ with archive.open(member) as source, open(destination, "wb") as target:
+ shutil.copyfileobj(source, target)
+ destination.chmod(0o755)
+ finally:
+ try:
+ zip_path.unlink(missing_ok=True)
+ except TypeError:
+ if zip_path.exists():
+ zip_path.unlink()
+
+ def _download_posix_build():
+ api_url = "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest"
+ response = requests.get(api_url, headers={"Accept": "application/vnd.github+json"}, timeout=30)
+ response.raise_for_status()
+ assets = response.json().get("assets", [])
+ if sys.platform.startswith("linux"):
+ keywords = ["linux64", "gpl"]
+ elif sys.platform == "darwin":
+ keywords = ["macos64", "gpl"]
+ else:
+ raise RuntimeError("Unsupported platform for automatic FFmpeg download.")
+
+ tar_asset = next(
+ (
+ asset for asset in assets
+ if asset.get("name", "").endswith(".tar.xz") and all(k in asset.get("name", "") for k in keywords)
+ ),
+ None
+ )
+ if not tar_asset:
+ raise RuntimeError("Unable to locate a suitable FFmpeg build for this platform.")
+
+ tar_path = bin_dir / tar_asset["name"]
+ _download_file(tar_asset["browser_download_url"], tar_path)
+ try:
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ tmp_path = Path(tmp_dir)
+ with tarfile.open(tar_path, "r:xz") as archive:
+ archive.extractall(tmp_path)
+
+ build_root = None
+ for candidate in tmp_path.iterdir():
+ if (candidate / "bin").exists():
+ build_root = candidate
+ break
+
+ if build_root is None:
+ raise RuntimeError("Unable to locate FFmpeg bin directory in downloaded archive.")
+
+ bin_source = build_root / "bin"
+ lib_source = build_root / "lib"
+
+ for binary in required_binaries:
+ source_file = bin_source / binary
+ if not source_file.exists():
+ continue
+ destination = bin_dir / binary
+ shutil.copy2(source_file, destination)
+ destination.chmod(0o755)
+
+ if lib_source.exists():
+ for lib_file in lib_source.rglob("*.so*"):
+ destination = bin_dir / lib_file.name
+ shutil.copy2(lib_file, destination)
+ destination.chmod(0o755)
+ finally:
+ try:
+ tar_path.unlink(missing_ok=True)
+ except TypeError:
+ if tar_path.exists():
+ tar_path.unlink()
+
+ try:
+ if os.name == "nt":
+ _download_windows_build()
+ else:
+ _download_posix_build()
+ except Exception as exc:
+ print(f"Failed to download FFmpeg binaries automatically: {exc}")
+ return
+
+ if not all(_binary_exists(binary) for binary in required_binaries):
+ print("FFmpeg binaries are still missing after download; please install them manually.")
+ return
+
+ _ensure_bin_dir_on_path()
+ _ensure_library_path()
+ _set_env_vars()
diff --git a/shared/utils/audio_video.py b/shared/utils/audio_video.py
index 5bf35df..74eb9a1 100644
--- a/shared/utils/audio_video.py
+++ b/shared/utils/audio_video.py
@@ -34,7 +34,23 @@ def extract_audio_tracks(source_video, verbose=False, query_only=False):
{'codec', 'sample_rate', 'channels', 'duration', 'language'}
where 'duration' is set to container duration (for consistency).
"""
- probe = ffmpeg.probe(source_video)
+ if not os.path.exists(source_video):
+ msg = f"ffprobe skipped; file not found: {source_video}"
+ if verbose:
+ print(msg)
+ raise FileNotFoundError(msg)
+
+ try:
+ probe = ffmpeg.probe(source_video)
+ except ffmpeg.Error as err:
+ stderr = getattr(err, 'stderr', b'')
+ if isinstance(stderr, (bytes, bytearray)):
+ stderr = stderr.decode('utf-8', errors='ignore')
+ stderr = (stderr or str(err)).strip()
+ message = f"ffprobe failed for {source_video}: {stderr}"
+ if verbose:
+ print(message)
+ raise RuntimeError(message) from err
audio_streams = [s for s in probe['streams'] if s['codec_type'] == 'audio']
container_duration = float(probe['format'].get('duration', 0.0))
@@ -428,4 +444,4 @@ def read_image_metadata(image_path):
return json.loads(s) if s else None
return None
except Exception as e:
- print(f"Error reading metadata: {e}"); return None
\ No newline at end of file
+ print(f"Error reading metadata: {e}"); return None
diff --git a/shared/utils/notification_sound.py b/shared/utils/notification_sound.py
index 26d1966..6945b84 100644
--- a/shared/utils/notification_sound.py
+++ b/shared/utils/notification_sound.py
@@ -1,12 +1,15 @@
-"""Add commentMore actions
-Notification sounds for Wan2GP video generation application
-Pure Python audio notification system with multiple backend support
+"""Notification sounds for Wan2GP video generation application.
+
+Pure Python audio notification system with multiple backend support.
+Set WAN2GP_DISABLE_AUDIO=1 on headless servers to skip pygame/sounddevice initialization.
+Set WAN2GP_FORCE_AUDIO=1 to bypass the automatic device detection when audio hardware is available.
"""
import os
import sys
import threading
-import time
+from pathlib import Path
+
import numpy as np
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
@@ -15,6 +18,81 @@ _cached_waveforms = {}
_sample_rate = 44100
_mixer_initialized = False
_mixer_lock = threading.Lock()
+_TRUE_VALUES = {"1", "true", "yes", "on"}
+
+
+def _env_flag(name):
+ value = os.environ.get(name, "")
+ return value.strip().lower() in _TRUE_VALUES
+
+
+_FORCE_AUDIO_BACKENDS = _env_flag("WAN2GP_FORCE_AUDIO")
+_DISABLE_AUDIO_BACKENDS = _env_flag("WAN2GP_DISABLE_AUDIO")
+_audio_support_cache = None
+_audio_support_reason = None
+_audio_backends_failed = False
+_last_beep_notice = None
+
+
+def _linux_audio_available():
+ cards_path = Path("/proc/asound/cards")
+ if not cards_path.exists():
+ return False, "/proc/asound/cards is missing (no ALSA devices)"
+ try:
+ cards_content = cards_path.read_text(errors="ignore")
+ except (OSError, UnicodeDecodeError):
+ cards_content = ""
+ if not cards_content.strip():
+ return False, "ALSA reports no soundcards (/proc/asound/cards is empty)"
+ if "no soundcards" in cards_content.lower():
+ return False, "ALSA reports no soundcards (/proc/asound/cards)"
+
+ snd_path = Path("/dev/snd")
+ if not snd_path.exists():
+ return False, "/dev/snd is not available"
+ try:
+ device_names = [entry.name for entry in snd_path.iterdir()]
+ except PermissionError:
+ return False, "no permission to inspect /dev/snd"
+ pcm_like = [
+ name
+ for name in device_names
+ if name.startswith(("pcm", "controlC", "hwC", "midiC"))
+ ]
+ if not pcm_like:
+ return False, "no ALSA pcm/control devices exposed under /dev/snd"
+ return True, None
+
+
+def _detect_audio_support():
+ if _FORCE_AUDIO_BACKENDS:
+ return True, None
+ if _DISABLE_AUDIO_BACKENDS:
+ return False, "disabled via WAN2GP_DISABLE_AUDIO"
+ if sys.platform.startswith("linux"):
+ return _linux_audio_available()
+ return True, None
+
+
+def _should_try_audio_backends():
+ global _audio_support_cache, _audio_support_reason
+ if _audio_backends_failed and not _FORCE_AUDIO_BACKENDS:
+ return False
+ if _audio_support_cache is None:
+ _audio_support_cache, _audio_support_reason = _detect_audio_support()
+ return _audio_support_cache
+
+
+def _terminal_beep(reason=None):
+ global _last_beep_notice
+ message = "Audio notification fallback: using terminal beep."
+ if reason:
+ message = f"Audio notification fallback: {reason}; using terminal beep."
+ if message != _last_beep_notice:
+ print(message)
+ _last_beep_notice = message
+ sys.stdout.write("\a")
+ sys.stdout.flush()
def _generate_notification_beep(volume=50, sample_rate=_sample_rate):
"""Generate pleasant C major chord notification sound"""
@@ -206,6 +284,11 @@ def play_notification_sound(volume=50):
if len(audio_data) == 0:
return
+ if not _should_try_audio_backends():
+ reason = _audio_support_reason or "audio backends unavailable"
+ _terminal_beep(reason)
+ return
+
audio_backends = [play_audio_with_pygame, play_audio_with_sounddevice, play_audio_with_winsound]
for backend in audio_backends:
try:
@@ -214,8 +297,9 @@ def play_notification_sound(volume=50):
except Exception:
continue
- print("All audio backends failed, using terminal beep")
- print("\a")
+ global _audio_backends_failed
+ _audio_backends_failed = True
+ _terminal_beep("all audio backends failed")
def play_notification_async(volume=50):
"""Play notification sound asynchronously (non-blocking)"""
diff --git a/wgp.py b/wgp.py
index 857fd7f..52ec5d1 100644
--- a/wgp.py
+++ b/wgp.py
@@ -10,6 +10,8 @@ if p not in sys.path:
import asyncio
if os.name == "nt":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+if sys.platform.startswith("linux") and "NUMBA_THREADING_LAYER" not in os.environ:
+ os.environ["NUMBA_THREADING_LAYER"] = "workqueue"
from shared.asyncio_utils import silence_proactor_connection_reset
silence_proactor_connection_reset()
import time
@@ -17,7 +19,8 @@ import threading
import argparse
import warnings
warnings.filterwarnings('ignore', message='Failed to find.*', module='triton')
-from mmgp import offload, safetensors2, profile_type
+from mmgp import offload, safetensors2, profile_type , fp8_quanto_bridge
+if not os.name == "nt": fp8_quanto_bridge.enable_fp8_marlin_fallback()
try:
import triton
except ImportError:
@@ -67,6 +70,7 @@ logging.set_verbosity_error
from tqdm import tqdm
import requests
from shared.gradio.gallery import AdvancedMediaGallery
+from shared.ffmpeg_setup import download_ffmpeg
from shared.utils.plugins import PluginManager, WAN2GPApplication, SYSTEM_PLUGINS
from collections import defaultdict
@@ -77,8 +81,8 @@ from collections import defaultdict
global_queue_ref = []
AUTOSAVE_FILENAME = "queue.zip"
PROMPT_VARS_MAX = 10
-target_mmgp_version = "3.6.7"
-WanGP_version = "9.42"
+target_mmgp_version = "3.6.8"
+WanGP_version = "9.43"
settings_version = 2.40
max_source_video_frames = 3000
prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None
@@ -167,31 +171,6 @@ def get_unique_id():
unique_id += 1
return str(time.time()+unique_id)
-def download_ffmpeg():
- if os.name != 'nt': return
- exes = ['ffmpeg.exe', 'ffprobe.exe', 'ffplay.exe']
- if all(os.path.exists(e) for e in exes): return
- api_url = 'https://api.github.com/repos/GyanD/codexffmpeg/releases/latest'
- r = requests.get(api_url, headers={'Accept': 'application/vnd.github+json'})
- assets = r.json().get('assets', [])
- zip_asset = next((a for a in assets if 'essentials_build.zip' in a['name']), None)
- if not zip_asset: return
- zip_url = zip_asset['browser_download_url']
- zip_name = zip_asset['name']
- with requests.get(zip_url, stream=True) as resp:
- total = int(resp.headers.get('Content-Length', 0))
- with open(zip_name, 'wb') as f, tqdm(total=total, unit='B', unit_scale=True) as pbar:
- for chunk in resp.iter_content(chunk_size=8192):
- f.write(chunk)
- pbar.update(len(chunk))
- with zipfile.ZipFile(zip_name) as z:
- for f in z.namelist():
- if f.endswith(tuple(exes)) and '/bin/' in f:
- z.extract(f)
- os.rename(f, os.path.basename(f))
- os.remove(zip_name)
-
-
def format_time(seconds):
hours = int(seconds // 3600)
minutes = int((seconds % 3600) // 60)