mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
IPEX fixes
This commit is contained in:
@@ -383,6 +383,7 @@
|
||||
{"id":"","label":"Model compile suppress errors","localized":"","hint":""},
|
||||
{"id":"","label":"Disable Torch memory garbage collection","localized":"","hint":"Disable Torch memory garbage collection on each generation. CG will still run before & after model load as well when low GPU memory threshold is reached."},
|
||||
{"id":"","label":"Directory for temporary images; leave empty for default","localized":"","hint":""},
|
||||
{"id":"","label":"Enable IPEX Optimize for Intel GPUs","localized":"","hint":""},
|
||||
{"id":"","label":"Cleanup non-default temporary directory when starting webui","localized":"","hint":""},
|
||||
{"id":"","label":"Path to directory with stable diffusion checkpoints","localized":"","hint":""},
|
||||
{"id":"","label":"Path to directory with stable diffusion diffusers","localized":"","hint":""},
|
||||
|
||||
@@ -382,6 +382,7 @@
|
||||
{"id":"","label":"Model compile verbose mode","localized":"","hint":""},
|
||||
{"id":"","label":"Model compile suppress errors","localized":"모델 컴파일 시 오류 억제","hint":""},
|
||||
{"id":"","label":"Disable Torch memory garbage collection","localized":"Torch 메모리 정리 비활성화","hint":"이미지 생성 시 메모리 정리를 하지 않는다. CG will still run before & after model load as well when low GPU memory threshold is reached."},
|
||||
{"id":"","label":"Enable IPEX Optimize for Intel GPUs","localized":"","hint":""},
|
||||
{"id":"","label":"Directory for temporary images; leave empty for default","localized":"임시 이미지 저장 위치 (비워 놓으면 기본값)","hint":""},
|
||||
{"id":"","label":"Cleanup non-default temporary directory when starting webui","localized":"임시 위치가 기본값이 아닌 경우 WebUI 시작 시 비우기","hint":""},
|
||||
{"id":"","label":"Path to directory with stable diffusion checkpoints","localized":"체크포인트 위치","hint":""},
|
||||
|
||||
@@ -185,8 +185,6 @@ def install(package, friendly: str = None, ignore: bool = False):
|
||||
if args.reinstall or args.upgrade:
|
||||
global quick_allowed # pylint: disable=global-statement
|
||||
quick_allowed = False
|
||||
if args.use_ipex and package == "pytorch_lightning==1.9.4":
|
||||
package = "pytorch_lightning==1.8.6"
|
||||
if args.reinstall or not installed(package, friendly):
|
||||
pip(f"install --upgrade {package}", ignore=ignore)
|
||||
|
||||
|
||||
@@ -21,39 +21,72 @@ def return_null_context(*args, **kwargs):
|
||||
return contextlib.nullcontext()
|
||||
|
||||
def ipex_init():
|
||||
#Fix functions with ipex
|
||||
torch.cuda.is_available = torch.xpu.is_available
|
||||
#Replace cuda with xpu:
|
||||
torch.cuda.current_device = torch.xpu.current_device
|
||||
torch.cuda.current_stream = torch.xpu.current_stream
|
||||
torch.cuda.device = torch.xpu.device
|
||||
torch.cuda.device_count = torch.xpu.device_count
|
||||
torch.cuda.current_device = torch.xpu.current_device
|
||||
torch.cuda.device_of = torch.xpu.device_of
|
||||
torch.cuda.getDeviceIdListForCard = torch.xpu.getDeviceIdListForCard
|
||||
torch.cuda.get_device_name = torch.xpu.get_device_name
|
||||
torch.cuda.get_device_properties = torch.xpu.get_device_properties
|
||||
torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access
|
||||
torch.cuda.init = torch.xpu.init
|
||||
torch.cuda.is_available = torch.xpu.is_available
|
||||
torch.cuda.is_initialized = torch.xpu.is_initialized
|
||||
torch.cuda.set_device = torch.xpu.set_device
|
||||
torch.cuda.stream = torch.xpu.stream
|
||||
torch.cuda.synchronize = torch.xpu.synchronize
|
||||
torch.backends.cuda.sdp_kernel = return_null_context
|
||||
torch.cuda.Event = torch.xpu.Event
|
||||
torch.Tensor.cuda = torch.Tensor.xpu
|
||||
torch.nn.DataParallel = DummyDataParallel
|
||||
torch.Tensor.is_cuda = torch.Tensor.is_xpu
|
||||
torch.cuda.Stream = torch.xpu.Stream
|
||||
|
||||
#Memory:
|
||||
torch.xpu.empty_cache = torch.xpu.empty_cache if "WSL2" not in os.popen("uname -a").read() else lambda: None
|
||||
torch.cuda.empty_cache = torch.xpu.empty_cache
|
||||
torch.cuda.ipc_collect = lambda: None
|
||||
torch.cuda.memory_stats = torch.xpu.memory_stats
|
||||
torch.cuda.mem_get_info = lambda device=None: [(torch.xpu.get_device_properties(device).total_memory - torch.xpu.memory_allocated(device)), torch.xpu.get_device_properties(device).total_memory]
|
||||
torch.cuda.memory_summary = torch.xpu.memory_summary
|
||||
torch.cuda.memory_snapshot = torch.xpu.memory_snapshot
|
||||
torch.cuda.memory_allocated = torch.xpu.memory_allocated
|
||||
torch.cuda.max_memory_allocated = torch.xpu.max_memory_allocated
|
||||
torch.cuda.memory_reserved = torch.xpu.memory_reserved
|
||||
torch.cuda.max_memory_reserved = torch.xpu.max_memory_reserved
|
||||
torch.cuda.reset_peak_memory_stats = torch.xpu.reset_peak_memory_stats
|
||||
torch.cuda.utilization = lambda: 0
|
||||
torch.cuda.memory_stats_as_nested_dict = torch.xpu.memory_stats_as_nested_dict
|
||||
torch.cuda.reset_accumulated_memory_stats = torch.xpu.reset_accumulated_memory_stats
|
||||
|
||||
#RNG:
|
||||
torch.cuda.get_rng_state = torch.xpu.get_rng_state
|
||||
torch.cuda.get_rng_state_all = torch.xpu.get_rng_state_all
|
||||
torch.cuda.set_rng_state = torch.xpu.set_rng_state
|
||||
torch.cuda.set_rng_state_all = torch.xpu.set_rng_state_all
|
||||
torch.cuda.manual_seed = torch.xpu.manual_seed
|
||||
torch.cuda.manual_seed_all = torch.xpu.manual_seed_all
|
||||
torch.cuda.seed = torch.xpu.seed
|
||||
torch.cuda.seed_all = torch.xpu.seed_all
|
||||
torch.cuda.initial_seed = torch.xpu.initial_seed
|
||||
|
||||
#Training:
|
||||
torch.cuda.get_rng_state_all = torch.xpu.get_rng_state_all
|
||||
torch.cuda.set_rng_state_all = torch.xpu.set_rng_state_all
|
||||
try:
|
||||
torch.cuda.amp.GradScaler = torch.xpu.amp.GradScaler
|
||||
except Exception:
|
||||
torch.cuda.amp.GradScaler = ipex.cpu.autocast._grad_scaler.GradScaler
|
||||
|
||||
#C
|
||||
torch._C._cuda_getCurrentRawStream = ipex._C._getCurrentStream
|
||||
ipex._C._DeviceProperties.major = 2023
|
||||
ipex._C._DeviceProperties.minor = 2
|
||||
|
||||
#Fix functions with ipex:
|
||||
torch.cuda.mem_get_info = lambda device=None: [(torch.xpu.get_device_properties(device).total_memory - torch.xpu.memory_allocated(device)), torch.xpu.get_device_properties(device).total_memory]
|
||||
torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access
|
||||
torch.xpu.empty_cache = torch.xpu.empty_cache if "WSL2" not in os.popen("uname -a").read() else lambda: None
|
||||
torch.cuda.get_device_properties.major = 2023
|
||||
torch.cuda.get_device_properties.minor = 2
|
||||
torch.backends.cuda.sdp_kernel = return_null_context
|
||||
torch.nn.DataParallel = DummyDataParallel
|
||||
torch.cuda.ipc_collect = lambda: None
|
||||
torch.cuda.utilization = lambda: 0
|
||||
|
||||
#Libraries that blindly uses cuda:
|
||||
#Adetailer:
|
||||
CondFunc('torch.Tensor.to',
|
||||
|
||||
@@ -96,10 +96,6 @@ if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v
|
||||
then
|
||||
echo "Launching accelerate launch.py..."
|
||||
exec accelerate launch --num_cpu_threads_per_process=6 launch.py "$@"
|
||||
elif [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v numactl)" ] && [ -x "$(command -v sycl-ls)" ]
|
||||
then
|
||||
echo "Launching ipexrun launch.py..."
|
||||
exec ipexrun launch.py "$@"
|
||||
else
|
||||
echo "Launching launch.py..."
|
||||
exec "${python_cmd}" launch.py "$@"
|
||||
|
||||
Reference in New Issue
Block a user