Skip to content

Commit

Permalink
Use cpu device
Browse files Browse the repository at this point in the history
  • Loading branch information
virajmalia committed May 19, 2024
1 parent a61199c commit 03498a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set device type to CPU for CI
run: |
sed -i s/"-DLLAMA_CUDA=on"/"-DLLAMA_BLAS=ON;-DLLAMA_BLAS_VENDOR=OpenBLAS"/g requirements.txt
sed -i s/tensorflow.*//g requirements.txt
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
./setup.sh
./setup.sh cpu
pip install flake8 huggingface-hub>=0.17.1
- name: Lint with flake8
run: |
Expand All @@ -37,7 +41,7 @@ jobs:
- name: Download model file
run: |
mkdir -p ./models/
huggingface-cli download PawanKrd/Llama-3-8B-Instruct-GGUF llama-3-8b-instruct.Q3_K_M.gguf --local-dir ./models/ --local-dir-use-symlinks False
huggingface-cli download PawanKrd/Llama-3-8B-Instruct-GGUF llama-3-8b-instruct.Q3_K_M.gguf --local-dir ./models/
- name: Test run
run: |
./llm.py ./models/ "Which is the best Llama model to use?"
32 changes: 18 additions & 14 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
#!/bin/bash

# nvidia GPU setup for Ubuntu 22.04
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
sudo apt update
sudo apt install cuda-toolkit-12-4
export PATH=/usr/local/cuda-12/bin:~/.local/bin:${PATH}
export CUDACXX=$(which nvcc)
if -z $CUDACXX; then
echo "nvcc not found in PATH."
exit /b 1
if [ "$1" != "cpu" ]; then
# nvidia GPU setup for Ubuntu 22.04
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
sudo apt update
sudo apt install cuda-toolkit-12-4
export PATH=/usr/local/cuda-12/bin:~/.local/bin:${PATH}
export CUDACXX=$(which nvcc)
if -z $CUDACXX; then
echo "nvcc not found in PATH."
exit /b 1
fi
echo $CUDACXX && $CUDACXX --version
fi
echo $CUDACXX && $CUDACXX --version

# project dependencies
sudo apt install python3-pip
pip install -r requirements.txt

# GPU device verification
# If not using GPU, comment or ignore this check and also remove tensorflow from requirements.txt
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" 2> /dev/null
if [ "$1" != "cpu" ]; then
# GPU device verification
# If not using GPU, comment or ignore this check and also remove tensorflow from requirements.txt
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" 2> /dev/null
fi

0 comments on commit 03498a6

Please sign in to comment.