Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python312Packages.llama-cpp-python: init at 0.3.1 #349657

Merged
merged 3 commits into from
Nov 30, 2024

Conversation

kirillrdy
Copy link
Member

@kirillrdy kirillrdy commented Oct 18, 2024

unlike previous attempt #268712

this uses bundled version of llama-cpp, also tested CUDA support

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@kirillrdy kirillrdy marked this pull request as ready for review October 19, 2024 00:15
@nix-owners nix-owners bot requested a review from natsukium October 19, 2024 00:16
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 labels Oct 19, 2024
@hoh
Copy link

hoh commented Oct 23, 2024

Thanks for the work !

Can you explain the motivations behind switching to the bundled version of llama-cpp ?

The package looks much simpler than the previous version that used patches on llama-cpp, but lacks support for other back-ends (OpenCL, ROCm).

@alexvorobiev
Copy link
Contributor

alexvorobiev commented Oct 23, 2024

Trying to build with Cuda results in the version error:

llama-cpp-python>   /nix/store/slx40i35cmd7kb3wvdqzckfww8smcy6s-cuda_nvcc-12.2.140/include/crt/host_config.h:143:2:
llama-cpp-python>   error: #error -- unsupported GNU version! gcc versions later than 12 are
llama-cpp-python>   not supported! The nvcc flag '-allow-unsupported-compiler' can be used to
llama-cpp-python>   override this version check; however, using an unsupported host compiler
llama-cpp-python>   may cause compilation failure or incorrect run time execution.  Use at your
llama-cpp-python>   own risk.

The usual workaround

....overridePythonAttrs(attrs: { stdenv = super.gcc12Stdenv; });

works, so it should be possible to add the override to the package.

@alexvorobiev
Copy link
Contributor

alexvorobiev commented Oct 23, 2024

Thanks for the work !

Can you explain the motivations behind switching to the bundled version of llama-cpp ?

The package looks much simpler than the previous version that used patches on llama-cpp, but lacks support for other back-ends (OpenCL, ROCm).

I am not the author but the code refers to the llama.cpp's subdirectories which are not included in nixpkg.llama-cpp. For instance https://github.com/abetlen/llama-cpp-python/blob/7403e002b8e033c0a34e93fba2b311e2118487fe/CMakeLists.txt#L110.

@kirillrdy
Copy link
Member Author

@hoh

Can you explain the motivations behind switching to the bundled version of llama-cpp ?

llama-cpp and llama-cpp-python often get out of sync, so using llama-cpp from nixpkgs requires either breaking lama-cpp-python or not updating llama-cpp

@alexvorobiev CUDA support builds without any overrides, do you change default cuda in your overlays ?

@alexvorobiev
Copy link
Contributor

alexvorobiev commented Oct 25, 2024

@alexvorobiev CUDA support builds without any overrides, do you change default cuda in your overlays ?

I have to use CUDA 12.2 for now, could that be the issue?

@kirillrdy
Copy link
Member Author

@alexvorobiev CUDA support builds without any overrides, do you change default cuda in your overlays ?

I have to use CUDA 12.2 for now, could that be the issue?

yes, it seems to only build with 12.4 ( which is default in nixpkgs )

@kirillrdy
Copy link
Member Author

@alexvorobiev I've fixed cuda build, tested with 12_3, 12_2, 12_1, 12_0, 11_8 ( stopped here )

@alexvorobiev
Copy link
Contributor

@alexvorobiev I've fixed cuda build, tested with 12_3, 12_2, 12_1, 12_0, 11_8 ( stopped here )

Thank you!

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-development-environment-for-python-ai-llama-3-1/56143/3

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-development-environment-for-python-ai-llama-3-1/56143/4

@MatthewCroughan MatthewCroughan merged commit aaa6191 into NixOS:master Nov 30, 2024
28 checks passed
@MatthewCroughan
Copy link
Contributor

Unsure if there are any outstanding issues, but best to merge instead of leaving the PR for a long time, so have merged and will try to use it and identify any outstanding issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants