[go: nahoru, domu]

Skip to content

Commit

Permalink
Add flag to disable macOS Metal for llama.cpp when running builds
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmezzetti committed May 28, 2024
1 parent 88adf4d commit 7f241b0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
run: |
echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV
echo "PYTORCH_MPS_DISABLE=1" >> $GITHUB_ENV
echo "LLAMA_NO_METAL=1" >> $GITHUB_ENV
echo "ACCELERATE_USE_CPU=1" >> $GITHUB_ENV
echo "TIKA_STARTUP_SLEEP=30" >> $GITHUB_ENV
echo "TIKA_STARTUP_MAX_RETRY=10" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion src/python/txtai/pipeline/llm/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, path, template=None, **kwargs):
path = path if os.path.exists(path) else self.download(path)

# Default GPU layers if not already set
kwargs["n_gpu_layers"] = kwargs.get("n_gpu_layers", -1 if kwargs.get("gpu", True) else 0)
kwargs["n_gpu_layers"] = kwargs.get("n_gpu_layers", -1 if kwargs.get("gpu", os.environ.get("LLAMA_NO_METAL") != "1") else 0)

# Create llama.cpp instance
self.llm = Llama(path, verbose=kwargs.pop("verbose", False), **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/python/txtai/vectors/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def loadmodel(self, path):
modelargs = self.config.get("vectors", {})

# Default GPU layers if not already set
modelargs["n_gpu_layers"] = modelargs.get("n_gpu_layers", -1 if self.config.get("gpu", True) else 0)
modelargs["n_gpu_layers"] = modelargs.get("n_gpu_layers", -1 if modelargs.get("gpu", os.environ.get("LLAMA_NO_METAL") != "1") else 0)

# Create llama.cpp instance
return Llama(path, verbose=modelargs.pop("verbose", False), embedding=True, **modelargs)
Expand Down

0 comments on commit 7f241b0

Please sign in to comment.