Skip to content

Commit

Permalink
refactor: simplified the installation of torch and sentence-transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
umbertogriffo committed May 4, 2024
1 parent b01665b commit b5a2b34
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 11 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ jobs:
with:
version: ${{ steps.poetry-version.outputs.poetry-version }}
virtualenvs-in-project: true
# Installing torch (CPU) and sentence-transformers with pip to avoid poetry's issues in installing torch.
# Installing llama-cpp-python without NVIDIA CUDA acceleration.

- name: Get llama-cpp version
id: llama-cpp-version
run: echo "llama-cpp-version=$(cat llama_cpp_version)" >> "$GITHUB_OUTPUT"

# Installing dependencies and llama-cpp-python without NVIDIA CUDA acceleration.
- name: Setup environment
run: |
poetry lock --check
poetry install --no-root --no-ansi
. .venv/bin/activate && pip3 install torch~=2.1.2 torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
. .venv/bin/activate && pip3 install sentence-transformers~=2.2.2
. .venv/bin/activate && pip3 install llama-cpp-python~=0.2.23
. .venv/bin/activate && pip3 install llama-cpp-python~=${{ steps.llama-cpp-version.outputs.llama-cpp-version }}
- name: Run tests
run: |
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: clean test
.PHONY: check install setup update test clean

file=llama_cpp_version
llama_cpp_version=`cat $(file)`

check:
which pip3
Expand All @@ -9,11 +12,8 @@ install:
mkdir -p .venv
poetry config virtualenvs.in-project true
poetry install --no-root --no-ansi
echo "Installing torch and sentence-transformers with pip to avoid poetry's issues in installing torch... (it doesn't install CUDA dependencies)"
. .venv/bin/activate && pip3 install torch~=2.1.2 torchvision torchaudio
. .venv/bin/activate && pip3 install sentence-transformers~=2.2.2
echo "Installing llama-cpp-python with pip to get NVIDIA CUDA acceleration"
. .venv/bin/activate && CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip3 install llama-cpp-python==0.2.28
. .venv/bin/activate && CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip3 install llama-cpp-python==$(llama_cpp_version)

install_pre_commit:
poetry run pre-commit install
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RAG (Retrieval-augmented generation) ChatBot
[![CI](https://github.com/umbertogriffo/rag-chatbot/workflows/CI/badge.svg)](https://github.com/umbertogriffo/rag-chatbot/actions/workflows/ci.yaml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

> [!IMPORTANT]
Expand Down
1 change: 1 addition & 0 deletions llama_cpp_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.28
Loading

0 comments on commit b5a2b34

Please sign in to comment.