Skip to content

Commit

Permalink
0.1.0: fixed README
Browse files Browse the repository at this point in the history
  • Loading branch information
mtasic85 committed Jul 18, 2024
1 parent 05dde60 commit 1015f1c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
[![Python][python-ver-image]][pypi-project-url]
[![License][mit-image]][mit-url]
-->
[![Downloads](https://img.shields.io/pypi/dm/llama-cli-cffi)](https://pypistats.org/packages/llama-cli-cffi)
[![Supported Versions](https://img.shields.io/pypi/pyversions/llama-cli-cffi)](https://pypi.org/project/llama-cli-cffi)
[![Downloads](https://img.shields.io/pypi/dm/llama-cpp-cffi)](https://pypistats.org/packages/llama-cpp-cffi)
[![Supported Versions](https://img.shields.io/pypi/pyversions/llama-cpp-cffi)](https://pypi.org/project/llama-cpp-cffi)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**Python** binding for [llama.cpp](https://github.com/ggerganov/llama.cpp) using **cffi** and **ctypes**. Supports **CPU** and **CUDA 12.5** execution.

## Install

```bash
pip install llama-cli-cffi
pip install llama-cpp-cffi
```

## Example
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "llama-cpp-cffi"
version = "0.0.4"
version = "0.1.0"
description = "Python binding for llama.cpp using cffi"
homepage = "https://github.com/mtasic85/llama-cpp-cffi"
repository = "https://github.com/mtasic85/llama-cpp-cffi"
Expand Down Expand Up @@ -35,8 +35,11 @@ script = "scripts/build.py"
[tool.cibuildwheel]
build-frontend = "build"
before-build = "pip install poetry"
# before-build = "pip install poetry; yum -y install wget"
skip = ["cp36-*", "cp37-*", "cp38-*", "cp39-*", "pp*", "*-win32", "*i686"]
build-verbosity=3
repair-wheel-command = ""
# environment = {"LD_LIBRARY_PATH" = "/project/cuda-12.5.1/dist/lib64:$LD_LIBRARY_PATH", "CUDA_HOME" = "/project/cuda-12.5.1/dist"}

[tool.cibuildwheel.pyodide]

Expand Down
21 changes: 14 additions & 7 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
import shutil
import subprocess
from pprint import pprint

from cffi import FFI

Expand All @@ -17,6 +18,7 @@ def clone_llama_cpp():
def build_cpu(*args, **kwargs):
# build static and shared library
env = os.environ.copy()
pprint(env)

#
# build llama.cpp
Expand Down Expand Up @@ -86,12 +88,17 @@ def build_cuda_12_5(*args, **kwargs):
cuda_file = 'cuda_12.5.1_555.42.06_linux.run'
cuda_url = f'https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/{cuda_file}'
cuda_output_dir = os.path.abspath('./cuda-12.5.1')
cuda_file_path = os.path.join(cuda_output_dir, cuda_file)

env['PATH'] = env['PATH'] + f':{cuda_output_dir}/dist/bin'
env['CUDA_PATH'] = f'{cuda_output_dir}/dist'

# download cuda file
subprocess.run(['wget', '-N', cuda_url, '-P', cuda_output_dir], check=True)
if not os.path.exists(cuda_file_path):
cmd = ['mkdir', '-p', f'{cuda_output_dir}']

subprocess.run(cmd, check=True)
subprocess.run(['curl', '-o', cuda_file_path, cuda_url], check=True)

# extract cuda file
cmd = ['chmod', '+x', f'{cuda_output_dir}/{cuda_file}']
Expand Down Expand Up @@ -169,11 +176,11 @@ def build_cuda_12_5(*args, **kwargs):
''',
libraries=[
'stdc++',
'cuda',
'cublas',
'culibos',
'cudart',
'cublasLt',
# 'cuda',
# 'cublas',
# 'culibos',
# 'cudart',
# 'cublasLt',
],
library_dirs=[f'{cuda_output_dir}/dist/lib64'],
extra_objects=['../llama.cpp/llama_cli.a'],
Expand Down Expand Up @@ -201,7 +208,7 @@ def build(*args, **kwargs):
build_cpu(*args, **kwargs)

# cuda 12.5
if os.environ['AUDITWHEEL_ARCH'] == 'x86_64':
if os.environ['AUDITWHEEL_POLICY'] == 'manylinux2014' and os.environ['AUDITWHEEL_ARCH'] == 'x86_64':
clean_llama_cpp()
build_cuda_12_5(*args, **kwargs)

Expand Down

0 comments on commit 1015f1c

Please sign in to comment.