diff --git a/README.md b/README.md index 37a1e9a..58a81b1 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ [![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. @@ -17,7 +17,7 @@ ## Install ```bash -pip install llama-cli-cffi +pip install llama-cpp-cffi ``` ## Example diff --git a/pyproject.toml b/pyproject.toml index 5583859..b4503e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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] diff --git a/scripts/build.py b/scripts/build.py index 922e1df..4fb7fe5 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -2,6 +2,7 @@ import glob import shutil import subprocess +from pprint import pprint from cffi import FFI @@ -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 @@ -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}'] @@ -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'], @@ -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)