Commit 11bada84 authored by Your Name's avatar Your Name

Fix CUDA backend for GGUF models - use VK_ICD_FILENAMES to disable Vulkan

- Use VK_ICD_FILENAMES=/dev/null to disable Vulkan ICD and force CUDA
- This is the correct variable for llama.cpp to disable Vulkan
- Restore VK_ICD_FILENAMES on cleanup for subsequent Vulkan models
parent f77d34da
...@@ -1584,9 +1584,8 @@ class VulkanBackend(ModelBackend): ...@@ -1584,9 +1584,8 @@ class VulkanBackend(ModelBackend):
if self.force_cuda: if self.force_cuda:
print("DEBUG: Forcing CUDA backend for llama-cpp-python...") print("DEBUG: Forcing CUDA backend for llama-cpp-python...")
# Disable Vulkan to ensure CUDA is used (llama-cpp with both CUDA+Vulkan needs this) # Disable Vulkan to ensure CUDA is used (llama-cpp with both CUDA+Vulkan needs this)
os.environ['GGML_DISABLE_VULKAN'] = '1' os.environ['VK_ICD_FILENAMES'] = '/dev/null' # Disable Vulkan ICD
os.environ['GGML_VULKAN_DEVICE'] = '' # Clear any Vulkan device selection print(f"DEBUG: Set VK_ICD_FILENAMES=/dev/null to disable Vulkan and force CUDA")
print(f"DEBUG: Set GGML_DISABLE_VULKAN=1 and GGML_VULKAN_DEVICE='' to force CUDA")
# Ensure CUDA is used - set environment to prefer CUDA # Ensure CUDA is used - set environment to prefer CUDA
if 'CUDA_VISIBLE_DEVICES' not in os.environ: if 'CUDA_VISIBLE_DEVICES' not in os.environ:
# Use all available CUDA devices # Use all available CUDA devices
...@@ -1971,11 +1970,9 @@ class VulkanBackend(ModelBackend): ...@@ -1971,11 +1970,9 @@ class VulkanBackend(ModelBackend):
def cleanup(self) -> None: def cleanup(self) -> None:
# When cleaning up a CUDA-forced model, restore Vulkan settings for future Vulkan models # When cleaning up a CUDA-forced model, restore Vulkan settings for future Vulkan models
if self.force_cuda: if self.force_cuda:
# Unset the CUDA-forcing environment variables so Vulkan models can work # Unset the CUDA-forcing environment variable so Vulkan models can work
if 'GGML_DISABLE_VULKAN' in os.environ: if 'VK_ICD_FILENAMES' in os.environ:
del os.environ['GGML_DISABLE_VULKAN'] del os.environ['VK_ICD_FILENAMES']
if 'GGML_VULKAN_DEVICE' in os.environ:
del os.environ['GGML_VULKAN_DEVICE']
print("DEBUG: Cleanup - restored Vulkan environment for future models") print("DEBUG: Cleanup - restored Vulkan environment for future models")
if self.model is not None: if self.model is not None:
del self.model del self.model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment