Skip to content
Python

add AMD support

Chris Malone7f7a2b2bb752
diff --git a/install.bat b/install.bat
index 675ddaa..a6378dc 100644
--- a/install.bat
+++ b/install.bat
@@ -7,7 +7,7 @@ cls
echo ======================================================
echo WAN2GP INSTALLER MENU
echo ======================================================
-echo 1. Automatic Install (Standard: venv)
+echo 1. Use 'venv' (Easiest - Comes prepackaged with python)
echo 2. Use 'uv' (Recommended - Handles Python 3.11 better)
echo 3. Use 'Conda'
echo 4. No Environment (Not Recommended)
diff --git a/setup.py b/setup.py
index c6519ac..e9f4bb2 100644
--- a/setup.py
+++ b/setup.py
@@ -14,25 +14,48 @@ ENV_MAP = {
}
def load_config():
+ if not os.path.exists(CONFIG_PATH):
+ print(f"Error: {CONFIG_PATH} not found.")
+ sys.exit(1)
with open(CONFIG_PATH, 'r') as f: return json.load(f)
-def get_gpu_name():
- try: return subprocess.check_output(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"], encoding='utf-8').strip()
- except: return None
+def get_gpu_info():
+ try:
+ name = subprocess.check_output(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"], encoding='utf-8').strip()
+ return name, "NVIDIA"
+ except: pass
+
+ try:
+ name = subprocess.check_output("wmic path win32_VideoController get name", shell=True, encoding='utf-8')
+ name = name.replace("Name", "").strip().split('\n')[0].strip()
+ if "Radeon" in name or "AMD" in name: return name, "AMD"
+ return name, "INTEL"
+ except: return "Unknown", "UNKNOWN"
-def get_profile_key(gpu):
- if not gpu: return "RTX_40"
- g = gpu.upper()
- if "50" in g: return "RTX_50"
- if "40" in g: return "RTX_40"
- if "30" in g: return "RTX_30"
- if "20" in g or "QUADRO" in g: return "RTX_20"
- return "GTX_10"
+def get_profile_key(gpu_name, vendor):
+ g = gpu_name.upper()
+ if vendor == "NVIDIA":
+ if "50" in g: return "RTX_50"
+ if "40" in g: return "RTX_40"
+ if "30" in g: return "RTX_30"
+ if "20" in g or "QUADRO" in g: return "RTX_20"
+ return "GTX_10"
+ elif vendor == "AMD":
+ if any(x in g for x in ["7600", "7700", "7800", "7900"]): return "AMD_GFX110X"
+ if any(x in g for x in ["7000", "Z1", "PHOENIX"]): return "AMD_GFX1151"
+ if any(x in g for x in ["8000", "STRIX", "1201"]): return "AMD_GFX1201"
+ return "AMD_GFX110X"
+ return "RTX_40"
-def run_cmd(cmd):
+def run_cmd(cmd, env_vars=None):
if not cmd: return
print(f"\n>>> Running: {cmd}")
- subprocess.run(cmd, shell=True, check=True)
+ custom_env = os.environ.copy()
+ if env_vars:
+ for k, v in env_vars.items():
+ print(f" [ENV SET] {k}={v}")
+ custom_env[k] = v
+ subprocess.run(cmd, shell=True, check=True, env=custom_env)
def list_installs():
found = []
@@ -47,7 +70,12 @@ def list_installs():
def get_active_env():
installs = list_installs()
- return installs[0] if installs else "none"
+ if not installs: return "none"
+ if len(installs) == 1: return installs[0]
+ print("\nMultiple environments detected:")
+ for i, env in enumerate(installs): print(f"{i+1}. {env}")
+ choice = input("Select environment to use: ")
+ return installs[int(choice)-1]
def install_from_keys(env_type, py_k, torch_k, triton_k, sage_k, flash_k, kernel_list, config):
env_dir = ENV_MAP[env_type]["dir"]
@@ -69,13 +97,15 @@ def install_from_keys(env_type, py_k, torch_k, triton_k, sage_k, flash_k, kernel
if triton_k: run_cmd(f"{pip} {config['components']['triton'][triton_k]['cmd']}")
if sage_k: run_cmd(f"{pip} {config['components']['sage'][sage_k]['cmd']}")
if flash_k: run_cmd(f"{pip} {config['components']['flash'][flash_k]['cmd']}")
- for k in kernel_list: run_cmd(f"{pip} {config['components']['kernels'][k]['cmd']}")
+ for k in kernel_list:
+ if k in config['components']['kernels']:
+ run_cmd(f"{pip} {config['components']['kernels'][k]['cmd']}")
def menu(title, options, recommended_key=None):
print(f"\n--- {title} ---")
keys = list(options.keys())
for i, k in enumerate(keys):
- rec = " [RECOMMENDED]" if k == recommended_key else ""
+ rec = " [RECOMMENDED FOR YOUR GPU]" if k == recommended_key else ""
print(f"{i+1}. {options[k]['label']}{rec}")
choice = input(f"Select option (Enter for Recommended): ")
if choice == "" and recommended_key: return recommended_key
@@ -90,11 +120,10 @@ def do_migrate(config):
if env == "none":
print("No environment found. Please run install.bat first.")
return
-
- confirm = input(f"This will nuke your {env} and rebuild with Python 3.11 / Torch 2.10.\nProceed? (y/n): ")
+
+ confirm = input(f"This will wipe your {env} and rebuild. Proceed? (y/n): ")
if confirm.lower() != 'y': return
- target = config['gpu_profiles']['RTX_50']
install_from_keys(env, target['python'], target['torch'], target['triton'], target['sage'], target['flash'], target['kernels'], config)
def do_upgrade(config):
@@ -102,8 +131,8 @@ def do_upgrade(config):
print(" WAN2GP MANUAL COMPONENT UPGRADE")
print("="*60)
env = get_active_env()
- gpu = get_gpu_name()
- rec = config['gpu_profiles'][get_profile_key(gpu)]
+ gpu_name, vendor = get_gpu_info()
+ rec = config['gpu_profiles'][get_profile_key(gpu_name, vendor)]
py_k = menu("Python Version", config['components']['python'], rec['python'])
torch_k = menu("Torch Version", config['components']['torch'], rec['torch'])
@@ -120,17 +149,26 @@ if __name__ == "__main__":
args = parser.parse_args()
cfg = load_config()
+ gpu_name, vendor = get_gpu_info()
+ profile_key = get_profile_key(gpu_name, vendor)
+ profile = cfg['gpu_profiles'][profile_key]
+
if args.mode == "install":
- p = cfg['gpu_profiles'][get_profile_key(get_gpu_name())]
- install_from_keys(args.env, p['python'], p['torch'], p['triton'], p['sage'], p['flash'], p['kernels'], cfg)
+ print(f"Hardware Detected: {gpu_name} ({vendor})")
+ install_from_keys(args.env, profile['python'], profile['torch'], profile['triton'], profile['sage'], profile.get('flash'), profile['kernels'], cfg)
+
elif args.mode == "run":
env = get_active_env()
- run_cmd(f"{ENV_MAP[env]['run'].format(dir=ENV_MAP[env]['dir'])} wgp.py")
+ env_vars = profile.get("env", {})
+ run_cmd(f"{ENV_MAP[env]['run'].format(dir=ENV_MAP[env]['dir'])} wgp.py", env_vars=env_vars)
+
elif args.mode == "update":
run_cmd("git pull")
env = get_active_env()
run_cmd(f"{ENV_MAP[env]['run'].format(dir=ENV_MAP[env]['dir'])} -m pip install -r requirements.txt")
+
elif args.mode == "migrate":
do_migrate(cfg)
+
elif args.mode == "upgrade":
do_upgrade(cfg)
\ No newline at end of file
diff --git a/setup_config.json b/setup_config.json
index 8cb30c1..503434e 100644
--- a/setup_config.json
+++ b/setup_config.json
@@ -7,7 +7,8 @@
"torch": {
"cu126": { "label": "Torch 2.6.0 + CUDA 12.6", "cmd": "torch==2.6.0+cu126 torchvision==0.21.0+cu126 torchaudio==2.6.0+cu126 --index-url https://download.pytorch.org/whl/cu126" },
"cu128": { "label": "Torch 2.7.1 + CUDA 12.8", "cmd": "torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128" },
- "cu130": { "label": "Torch 2.10.0 + CUDA 13.0", "cmd": "torch==2.10.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130" }
+ "cu130": { "label": "Torch 2.10.0 + CUDA 13.0 (Nvidia Recommended)", "cmd": "torch==2.10.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130" },
+ "rocm65": { "label": "ROCm 6.5 (TheRock) for AMD Windows", "cmd": "https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torch-2.7.0a0+rocm_git3f903c3-cp311-cp311-win_amd64.whl https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchvision-0.22.0+9eb57cd-cp311-cp311-win_amd64.whl https://github.com/scottt/rocm-TheRock/releases/download/v6.5.0rc-pytorch-gfx110x/torchaudio-2.7.0a0+52638ef-cp311-cp311-win_amd64.whl" }
},
"triton": {
"v33": { "label": "Triton-Windows < 3.3", "cmd": "-U \"triton-windows<3.3\"" },
@@ -30,10 +31,13 @@
}
},
"gpu_profiles": {
- "GTX_10": { "python": "3.10", "torch": "cu126", "triton": null, "sage": null, "flash": null, "kernels": [] },
- "RTX_20": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v1", "flash": null, "kernels": [] },
- "RTX_30": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v211", "flash": null, "kernels": [] },
- "RTX_40": { "python": "3.10", "torch": "cu128", "triton": "v34", "sage": "v220", "flash": "v271", "kernels": ["nunchaku"] },
- "RTX_50": { "python": "3.11", "torch": "cu130", "triton": "latest", "sage": "v220_cu13", "flash": "v210", "kernels": ["light2xv"] }
+ "GTX_10": { "python": "3.10", "torch": "cu126", "triton": null, "sage": null, "flash": null, "kernels": [] },
+ "RTX_20": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v1", "flash": null, "kernels": [] },
+ "RTX_30": { "python": "3.10", "torch": "cu126", "triton": "v33", "sage": "v211", "flash": null, "kernels": [] },
+ "RTX_40": { "python": "3.10", "torch": "cu128", "triton": "v34", "sage": "v220", "flash": "v271", "kernels": ["nunchaku"] },
+ "RTX_50": { "python": "3.11", "torch": "cu130", "triton": "latest", "sage": "v220_cu13", "flash": "v210", "kernels": ["light2xv"] },
+ "AMD_GFX110X": { "python": "3.11", "torch": "rocm65", "triton": null, "sage": null, "flash": null, "kernels": [], "env": {"HSA_OVERRIDE_GFX_VERSION": "11.0.0"} },
+ "AMD_GFX1151": { "python": "3.11", "torch": "rocm65", "triton": null, "sage": null, "flash": null, "kernels": [], "env": {"HSA_OVERRIDE_GFX_VERSION": "11.5.1"} },
+ "AMD_GFX1201": { "python": "3.11", "torch": "rocm65", "triton": null, "sage": null, "flash": null, "kernels": [], "env": {"HSA_OVERRIDE_GFX_VERSION": "12.0.1"} }
}
}
\ No newline at end of file