Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ docker run -ti --name local-ai -p 8080:8080 --device=/dev/kfd --device=/dev/dri

```bash
# Intel GPU with FP16 support
docker run -ti --name local-ai -p 8080:8080 localai/localai:latest-gpu-intel-f16
docker run -ti --name local-ai -p 8080:8080 --device=/dev/dri/card1 --device=/dev/dri/renderD128 localai/localai:latest-gpu-intel-f16

# Intel GPU with FP32 support
docker run -ti --name local-ai -p 8080:8080 localai/localai:latest-gpu-intel-f32
docker run -ti --name local-ai -p 8080:8080 --device=/dev/dri/card1 --device=/dev/dri/renderD128 localai/localai:latest-gpu-intel-f32
```

### Vulkan GPU Images:
Expand Down
15 changes: 7 additions & 8 deletions backend/python/diffusers/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
FRAMES = os.environ.get("FRAMES", "64")

if XPU:
import intel_extension_for_pytorch as ipex

print(ipex.xpu.get_device_name(0))
print(torch.xpu.get_device_name(0))

# If MAX_WORKERS are specified in the environment use it, otherwise default to 1
MAX_WORKERS = int(os.environ.get('PYTHON_GRPC_MAX_WORKERS', '1'))
Expand Down Expand Up @@ -336,6 +334,8 @@ def LoadModel(self, request, context):
request.LoraAdapter = os.path.join(request.ModelPath, request.LoraAdapter)

device = "cpu" if not request.CUDA else "cuda"
if XPU:
device = "xpu"
self.device = device
if request.LoraAdapter:
# Check if its a local file and not a directory ( we load lora differently for a safetensor file )
Expand All @@ -359,12 +359,11 @@ def LoadModel(self, request, context):

self.pipe.set_adapters(adapters_name, adapter_weights=adapters_weights)

if request.CUDA:
self.pipe.to('cuda')
if device != "cpu":
self.pipe.to(device)
if self.controlnet:
self.controlnet.to('cuda')
if XPU:
self.pipe = self.pipe.to("xpu")
self.controlnet.to(device)

except Exception as err:
return backend_pb2.Result(success=False, message=f"Unexpected {err=}, {type(err)=}")
# Implement your logic here for the LoadModel service
Expand Down
8 changes: 7 additions & 1 deletion backend/python/diffusers/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ else
source $backend_dir/../common/libbackend.sh
fi

startBackend $@
if [ -d "/opt/intel" ]; then
# Assumes we are using the Intel oneAPI container image
# https://github.com/intel/intel-extension-for-pytorch/issues/538
export XPU=1
fi

startBackend $@
Loading