# 在 Linux 下編譯 Ollama 原始碼支援 NVIDIA H100 的可執行檔: * 官版已經從0.3.7之後支援了 CUDA 12,所以如果使用官版運行正常,就不需要依照以下程序自己建立可執行檔了。 1. 先安裝 [golang](https://go.dev/doc/install) 和 cmake 以及 [NVIDIA CUDA 開發套件](https://developer.nvidia.com/cuda-downloads),這些需要使用系統管理員帳號。因為我們需要支援 nVidia H100 ,所以請抓 CUDA 12 之後的套件來安裝。 2. 環境參數 CMAKE_CUDA_ARCHITECTURES 要設定為 `"50;60;70;80;90"`,其中 `90` 是指 H100。在 shell 下輸入 `export CMAKE_CUDA_ARCHITECTURES="50;60;70;80;90"` 3. 下載 Github 上的 ollama 原始碼:`git clone https://github.com/ollama/ollama.git` 4. 切換到 ollama 子目錄。 5. 輸入 `go generate ./...` 開始連結相關的套件跟做成編譯用的組態檔。這一步驟需要一點時間。 6. 切換到 version 子目錄,編輯 version.go 檔裡面的版本號碼,例如:`"0.3.6-H100"` 7. 切回上一層目錄。 `cd ..` 8. 開始編譯,輸入 `go build .` 9. 編譯成功之後,在本目錄下會看到一個名稱為 ollama 的可執行檔。 10. 將它移到 /usr/local/bin ,或是做一個 symbolic link 指向它。 11. 重新啟動 ollama,輸入 `ollama --version` 檢查看看是不是你編好的版號。如果是,恭喜。 # Build from Ollama source code under Linux to support NVIDIA H100 : * The official version has supported CUDA 12 since 0.3.7, so if it runs normally, you do not need to follow the following procedures to build the executable file yourself. 1. First, install [golang](https://go.dev/doc/install), cmake, and [NVIDIA CUDA Development Kit](https://developer.nvidia.com/cuda-downloads), which requires the use of system adminstrator account. Because we need to support nVidia H100, please download a package and runtime after CUDA 12 to install it. 2. You can customize a set of target CUDA architectures by setting CMAKE_CUDA_ARCHITECTURES environment parameter to `"50;60;70;80;90"`, where `90` refers to H100. Enter `export CMAKE_CUDA_ARCHITECTURES="50;60;70;80;90"` under the shell. 3. Download the ollama source code on Github: `git clone https://github.com/ollama/ollama.git` 4. Switch to the ollama subdirectory. 5. Enter `go generate ./...` to start linking related packages and creating configuration files for compilation. This step takes a while. 6. Switch to the version subdirectory and edit the version number in the version.go file, for example: `"0.3.6-H100"` 7. Switch back to the previous directory. `cd ..` 8. To start build code, enter `go build .` 9. After successful compilation, you will see an executable file named ollama in this directory. 10. Move it to '/usr/local/bin', or make a symbolic link pointing to it. 11. Restart ollama, enter `ollama --version` to check whether it is the version number you programmed. If so, congratulations.