Feature: Intel ARC GPU support with IPEX (#1204)

* Initial Intel ARC support with IPEX

* Fix infer

* Fix train model

* Cleanup

* Cleanup

* Update README

* Make pylint happy

* Move dataloader fix to hijacks

* Fix torch.linalg.solve

* Fix SDP

* Add has_xpu to config.py

* Revert return_xpu fix
This commit is contained in:
Disty0
2023-09-09 07:00:29 +03:00
committed by GitHub
parent c761bda09a
commit 0c94f60093
13 changed files with 817 additions and 20 deletions

View File

@@ -5,7 +5,13 @@ import json
from multiprocessing import cpu_count
import torch
try:
import intel_extension_for_pytorch as ipex # pylint: disable=import-error, unused-import
if torch.xpu.is_available():
from infer.modules.ipex import ipex_init
ipex_init()
except Exception:
pass
import logging
logger = logging.getLogger(__name__)
@@ -103,12 +109,22 @@ class Config:
except Exception:
return False
@staticmethod
def has_xpu() -> bool:
if hasattr(torch, "xpu") and torch.xpu.is_available():
return True
else:
return False
def use_fp32_config(self):
for config_file in version_config_list:
self.json_config[config_file]["train"]["fp16_run"] = False
def device_config(self) -> tuple:
if torch.cuda.is_available():
if self.has_xpu():
self.device = self.instead = "xpu:0"
self.is_half = True
i_device = int(self.device.split(":")[-1])
self.gpu_name = torch.cuda.get_device_name(i_device)
if (