Giter VIP home page Giter VIP logo

ollama-flake's Introduction

Ollama Nix Flake

This flake has been mostly abandoned, and won't receive consistent updates.

A flake for the latest release of ollama. It's purpose is to build the most recent version supporting new models until the version in nixpkgs is updated.

Contents

Install

You need to have nix flakes enabled; if you don't, see the nixos wiki for information on flakes and enabling them.

Install ollama to user profile:

nix profile install github:abysssol/ollama-flake

Create a temporary shell with ollama:

nix shell github:abysssol/ollama-flake

Use as an input in another flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    ollama.url = "github:abysssol/ollama-flake";
    #ollama.inputs.nixpkgs.follows = "nixpkgs"; # this could break the build unless using unstable nixpkgs
  };

  outputs = { nixpkgs, ollama, ... }:
    let
      system = abort "system needs to be set";
      # to access the rocm package of the ollama flake:
      ollama-rocm = ollama.packages.${system}.rocm;
      #ollama-rocm = inputs'.ollama.packages.rocm; # with flake-parts

      pkgs = nixpkgs.legacyPackages.${system};
      # you can override package inputs like with nixpkgs
      ollama-cuda = ollama.packages.${system}.cuda.override { cudaGcc = pkgs.gcc11; };
    in
    {
      # output attributes go here
    };
};

Version

You can specify a version by appending /<version> after the main url, where <version> is any branch or tag. The version branches will only be updated in a backward compatible way, no breaking changes (see semantic versioning).

Append /3 to follow branch 3 which tracks version 3.y.z of the repo:

nix profile install github:abysssol/ollama-flake/3

Use an unchanging tagged version:

nix profile install github:abysssol/ollama-flake/3.5.0

Alternate packages can be specified as usual. From version 3, install the cpu package, which is built to only run on CPU:

nix profile install github:abysssol/ollama-flake/3#cpu

Other versions may be available:

nix profile install github:abysssol/ollama-flake/1
nix profile install github:abysssol/ollama-flake/1.7.0

Backend

Multiple packages are available for the different computation backends supported by ollama on linux. On other platforms (eg darwin), only the default package is available. On darwin, gpu acceleration via metal should work by default.

The available options:

  • cpu: fallback CPU implementation
    nix profile install github:abysssol/ollama-flake#cpu
  • rocm: supported by most modern AMD GPUs
    nix profile install github:abysssol/ollama-flake#rocm
  • cuda: supported by most modern NVIDIA GPUs; uses unfree licensed libraries
    nix profile install github:abysssol/ollama-flake#cuda

The default builds for cpu:

# both of these are the default package, and are equivalent
nix profile install github:abysssol/ollama-flake
nix profile install github:abysssol/ollama-flake#default
# both of the above are equivalent to the one below
nix profile install github:abysssol/ollama-flake#cpu

Update

Find the index of the package to update:

nix profile list

Update the package at index:

nix profile upgrade $index

If nix is hesitant to download updates, force nix to download new files with --refresh:

nix profile upgrade --refresh $index

Remove

Find the index of the package to remove:

nix profile list

Remove the package at index:

nix profile remove $index

License

This software is dedicated to the public domain under the Creative Commons Zero. Read the CC0 in the LICENSE file or online.

Contribution

Any contribution submitted for inclusion in the project is subject to the CC0; that is, it is released into the public domain and all copyright to it is relinquished.

ollama-flake's People

Contributors

abysssol avatar mastoca avatar vrinek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ollama-flake's Issues

No such file or directory for GPU arch : gfx1035

Hello,
I don't know if it should be the best place for this issue (maybe it belongs to the ollama official repository).
My laptop has an iGPU AMD Radeon™ 680M.

I am using the flake to build ollama with rocm support.

{
  description = "learning";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/master";
    ollama.url = "github:abysssol/ollama-flake";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, ollama, flake-utils }:

  flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      ollama-rocm = ollama.packages.${system}.rocm;
    in {

      devShell = pkgs.mkShell {
        buildInputs = with pkgs; [
         
          valgrind
          poetry
          ruff
          stdenv.cc.cc.lib
          ollama-rocm
        ];
        LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
      };
  });
}

When I try to generate some tokens via the API (I tried with mistral and phi) I have the following trace:

> ollama serve                                                                                                        nix-shell-env
time=2024-02-25T20:58:47.533+01:00 level=INFO source=images.go:710 msg="total blobs: 19"
time=2024-02-25T20:58:47.533+01:00 level=INFO source=images.go:717 msg="total unused blobs removed: 0"
time=2024-02-25T20:58:47.534+01:00 level=INFO source=routes.go:1019 msg="Listening on 127.0.0.1:11434 (version 0.1.26)"
time=2024-02-25T20:58:47.534+01:00 level=INFO source=payload_common.go:107 msg="Extracting dynamic libraries..."
time=2024-02-25T20:58:47.799+01:00 level=INFO source=payload_common.go:146 msg="Dynamic LLM libraries [cpu cpu_avx2 rocm cpu_avx]"
time=2024-02-25T20:58:47.799+01:00 level=INFO source=gpu.go:94 msg="Detecting GPU type"
time=2024-02-25T20:58:47.799+01:00 level=INFO source=gpu.go:265 msg="Searching for GPU management library libnvidia-ml.so"
time=2024-02-25T20:58:47.799+01:00 level=INFO source=gpu.go:311 msg="Discovered GPU libraries: []"
time=2024-02-25T20:58:47.799+01:00 level=INFO source=gpu.go:265 msg="Searching for GPU management library librocm_smi64.so"
time=2024-02-25T20:58:47.799+01:00 level=INFO source=gpu.go:311 msg="Discovered GPU libraries: [/nix/store/0x1y6by0mjcm1gn91rdn0bq5bh0f6l1i-rocm-smi-5.7.1/lib/librocm_smi64.so.5.0]"
time=2024-02-25T20:58:47.803+01:00 level=INFO source=gpu.go:109 msg="Radeon GPU detected"
time=2024-02-25T20:58:47.803+01:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-02-25T20:58:58.038+01:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-02-25T20:58:58.039+01:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-02-25T20:58:58.039+01:00 level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
loading library /tmp/nix-shell.YHbFgT/ollama2810121158/rocm/libext_server.so
time=2024-02-25T20:58:58.109+01:00 level=INFO source=dyn_ext_server.go:90 msg="Loading Dynamic llm server: /tmp/nix-shell.YHbFgT/ollama2810121158/rocm/libext_server.so"
time=2024-02-25T20:58:58.109+01:00 level=INFO source=dyn_ext_server.go:150 msg="Initializing llama server"

rocBLAS error: Cannot read /nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary.dat: No such file or directory for GPU arch : gfx1035
 List of available TensileLibrary Files :
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx940.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx1100.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx908.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx1030.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx90a.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx942.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx906.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx900.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx1102.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx941.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx1101.dat"
"/nix/store/ialcylww20hrrzy91agi6ncqrk528fzs-rocblas-5.7.1/lib/rocblas/library/TensileLibrary_lazy_gfx803.dat"
[1]    409190 IOT instruction (core dumped)  ollama serve

Do you see any obvious issue ?

Thank you very much.

Update to the latest ollama version

Hi. ollama has changed a lot since 0.1.17. ollama doesn't call the llama-cpp's executable on its own anymore but use their libraries. And very recently rocm support.

Any plans on updating your flake to the latest ollama version?

GPU not detected -- RM detects a driver/library version mismatch.

Hi - I just wondered if you had some thoughts. I have a machine with some NVIDIA 2080 Supers in that, for some reason, doesn't detect the GPU and launches in CPU only mode. Happy to go over to Ollama directly if you're not sure. However thought that maybe you might have come across this so worth asking first. Thanks for looking at this either way.

I'm still working on a flake from prior to your changes to wrap around your nixpkgs fork (as of this moment, that doesn't work for me). Tried using the gpu/cuda package. I've used this on another machine and it works flawlessly (thanks for your hard work on this!).

I noticed I have this here:

67ffy95f824kxbvx4s6an9150sd6zazl-nvidia-x11-545.29.06-6.1.75/lib/libnvidia-ml.so.545.29.06: nvml vram init failure: 18"

To clarify I'm able to run pytorch with CUDA on a GPU from within a flake, so I believe the system is setup correctly. Again, happy to open an issue with Ollama if you don't believe you can help.

Full log of opening ollama serve.

time=2024-02-14T19:13:12.975Z level=INFO source=images.go:863 msg="total blobs: 6"
time=2024-02-14T19:13:12.975Z level=INFO source=images.go:870 msg="total unused blobs removed: 0"
time=2024-02-14T19:13:12.975Z level=INFO source=routes.go:999 msg="Listening on 127.0.0.1:11434 (version 0.1.24)"
time=2024-02-14T19:13:12.975Z level=INFO source=payload_common.go:106 msg="Extracting dynamic libraries..."
time=2024-02-14T19:13:17.529Z level=INFO source=payload_common.go:145 msg="Dynamic LLM libraries [cuda_v12 rocm cpu_avx cpu cpu_avx2]"
time=2024-02-14T19:13:17.529Z level=INFO source=gpu.go:94 msg="Detecting GPU type"
time=2024-02-14T19:13:17.529Z level=INFO source=gpu.go:242 msg="Searching for GPU management library libnvidia-ml.so"
time=2024-02-14T19:13:17.529Z level=INFO source=gpu.go:288 msg="Discovered GPU libraries: [/nix/store/67ffy95f824kxbvx4s6an9150sd6zazl-nvidia-x11-545.29.06-6.1.75/lib/libnvidia-ml.so.545.29.06]"
time=2024-02-14T19:13:17.533Z level=INFO source=gpu.go:300 msg="Unable to load CUDA management library /nix/store/67ffy95f824kxbvx4s6an9150sd6zazl-nvidia-x11-545.29.06-6.1.75/lib/libnvidia-ml.so.545.29.06: nvml vram init failure: 18"
time=2024-02-14T19:13:17.533Z level=INFO source=gpu.go:242 msg="Searching for GPU management library librocm_smi64.so"
time=2024-02-14T19:13:17.533Z level=INFO source=gpu.go:288 msg="Discovered GPU libraries: [/nix/store/0x1y6by0mjcm1gn91rdn0bq5bh0f6l1i-rocm-smi-5.7.1/lib/librocm_smi64.so.5.0]"
time=2024-02-14T19:13:17.534Z level=INFO source=gpu.go:317 msg="Unable to load ROCm management library /nix/store/0x1y6by0mjcm1gn91rdn0bq5bh0f6l1i-rocm-smi-5.7.1/lib/librocm_smi64.so.5.0: rocm vram init failure: 8"
time=2024-02-14T19:13:17.534Z level=INFO source=cpu_common.go:11 msg="CPU has AVX2"
time=2024-02-14T19:13:17.534Z level=INFO source=routes.go:1022 msg="no GPU detected"

Updating `nixpkgs` ?

Hello,

I'm reaching out to kindly inquire about the rationale behind creating an external flake, given that there's an existing upstream version in nixpkgs, outdated sure, but existing. I'm genuinely curious to understand the challenges or considerations that might have led to the decision to maintain a separate version rather than contributing your changes back to nixpkgs.

Please know that my intention is purely to understand the situation better and to explore how I might help backporting your changes in nixpkgs.

Thanks!

CUDA unsupported GNU version! gcc versions later than 11 are not supported!

Hi, I'm trying to compila the gpu version, but fail with this:

 #error -- unsupported GNU version! gcc versions later than 11 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.

I have an NVidia 3060 Laptop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.