我要评分
获取效率
正确性
完整性
易理解

Source Code Compilation and Build

Obtain the Ollama source code, build the CUDA 13 acceleration library and Ollama command line program from the source code, and install the local build products.

  1. Obtain the Ollama 0.19.0 source code.
    1
    2
    git clone --branch v0.19.0 --depth 1
    https://github.com/ollama/ollama.git
    
  2. Build the CUDA 13 acceleration library from the source code.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    cd ollama
    export CUDA_HOME=/usr/local/cuda-13.0
    export PATH=/usr/local/go/bin:$CUDA_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$CUDA_HOME/lib64:${LD_LIBRARY_PATH:-}
    
    cmake -B build --preset "CUDA 13" \
      -DCMAKE_CUDA_ARCHITECTURES=80 \
      -DCMAKE_CUDA_FLAGS="-t 1"
    cmake --build build --preset "CUDA 13" --parallel 8
    cmake --install build --component CUDA --prefix /tmp/ollama-build
    
  3. Build the Ollama command line program from the source code.
    1
    2
    go build -trimpath -ldflags "-X github.com/ollama/ollama/version.Version=0.19.0" \
      -o /tmp/ollama-build/ollama .
    
  4. Install the local build products.
    1
    install -m 0755 /tmp/ollama-build/ollama /usr/local/bin/ollama
    

    The following is an example of the build products.

    1
    2
    ollama 
    lib/ollama/cuda_v13/libggml-cuda.so