From 926af8eb6f7974ddd44613438bbcf514bd540509 Mon Sep 17 00:00:00 2001 From: AKharytonchyk Date: Mon, 2 Jun 2025 07:49:55 +0200 Subject: [PATCH] chore: Add changes to support AMD on Linux --- comfy/model_management.py | 4 ++-- start.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 start.sh diff --git a/comfy/model_management.py b/comfy/model_management.py index f5b37e68e..a3c22dd3e 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -169,7 +169,7 @@ def get_torch_device(): elif is_mlu(): return torch.device("mlu", torch.mlu.current_device()) else: - return torch.device(torch.cuda.current_device()) + return torch.device("cuda") def get_total_memory(dev=None, torch_total_too=False): global directml_enabled @@ -202,7 +202,7 @@ def get_total_memory(dev=None, torch_total_too=False): mem_total = mem_total_mlu else: stats = torch.cuda.memory_stats(dev) - mem_reserved = stats['reserved_bytes.all.current'] + mem_reserved = torch.cuda.memory_reserved(dev) _, mem_total_cuda = torch.cuda.mem_get_info(dev) mem_total_torch = mem_reserved mem_total = mem_total_cuda diff --git a/start.sh b/start.sh new file mode 100755 index 000000000..c856bd4af --- /dev/null +++ b/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Start ComfyUI with AMD Radeon 7900 XTX (ROCm) + +# Set ROCm architecture for Radeon 7900 XTX +echo "Setting ROCm environment for Radeon 7900 XTX (gfx1100)" +export PYTORCH_ROCM_ARCH=gfx1100 +# Uncomment the next line if you encounter issues with ROCm version detection +export HSA_OVERRIDE_GFX_VERSION=11.0.0 + +# Optionally, activate your Python virtual environment here +source ../venv/bin/activate + +# Start ComfyUI +python3 main.py --lowvram --use-split-cross-attention --fp16-unet --listen 0.0.0.0 "$@"