Skip to content

Commit fad59bb

Browse files
authored
Improve interface compatibility (#954)
* Improve interface compatibility Add Dockerfile for Linux platform * del unimportant comments * Update README.md
1 parent 0e838a4 commit fad59bb

File tree

8 files changed

+119
-38
lines changed

8 files changed

+119
-38
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM ubuntu:20.04
2+
3+
SHELL ["/bin/bash", "-c"]
4+
5+
ENV no_proxy=http://Child-mu.intel.com:912
6+
ENV ftp_proxy=http://Child-mu.intel.com:912
7+
ENV http_proxy=http://Child-mu.intel.com:912
8+
ENV https_proxy=http://Child-mu.intel.com:912
9+
10+
RUN apt-get update && apt install -y software-properties-common
11+
RUN add-apt-repository ppa:deadsnakes/ppa \
12+
&& apt-get update \
13+
&& apt-get install -y python3.10
14+
RUN ln -sf /usr/bin/python3.10 /usr/bin/python3
15+
16+
RUN apt-get install -y ca-certificates git wget curl gcc g++ \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
WORKDIR /home/ollama_ov_server
21+
ARG GOVERSION=1.24.1
22+
RUN curl -fsSL https://golang.org/dl/go${GOVERSION}.linux-$(case $(uname -m) in x86_64) echo amd64 ;; aarch64) echo arm64 ;; esac).tar.gz | tar xz -C /usr/local
23+
ENV PATH=/usr/local/go/bin:$PATH
24+
25+
RUN wget https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_ubuntu20_2025.2.0.0.dev20250320_x86_64.tar.gz
26+
RUN tar -xzf openvino_genai_ubuntu20_2025.2.0.0.dev20250320_x86_64.tar.gz
27+
ENV GENAI_DIR=/home/ollama_ov_server/openvino_genai_ubuntu20_2025.2.0.0.dev20250320_x86_64
28+
29+
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GENAI_DIR/runtime/3rdparty/tbb/lib:$GENAI_DIR/runtime/lib/intel64
30+
31+
ENV CGO_ENABLED=1
32+
ENV GODEBUG=cgocheck=0
33+
34+
ENV CGO_LDFLAGS=-L$GENAI_DIR/runtime/lib/intel64
35+
ENV CGO_CFLAGS=-I$GENAI_DIR/runtime/include
36+
37+
WORKDIR /home/ollama_ov_server
38+
RUN git clone https://github.com/zhaohb/ollama_ov.git
39+
WORKDIR /home/ollama_ov_server/ollama_ov
40+
41+
RUN go build -o /bin/ollama .
42+
43+
ENV OLLAMA_HOST=0.0.0.0:11434
44+
EXPOSE 11434
45+
ENTRYPOINT ["/bin/ollama"]
46+
CMD ["serve"]

modules/ollama_openvino/README.md

Lines changed: 61 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ See the [API documentation](./docs/api.md) for all endpoints.
578578
Getting started with large language models and using the [GenAI](https://github.com/openvinotoolkit/openvino.genai) backend.
579579

580580
<div style="text-align:center;">
581-
<img src="./images/ollama_ov_streaming.gif" alt="Ollama-OV" width="900" height="400">
581+
<img src="./images/ollama_openvino_new.gif" alt="Ollama-OV" width="900" height="400">
582582
</div>
583583

584584
We provide two ways to download the executable file of Ollama, one is to download it from Google Drive, and the other is to download it from Baidu Drive:
@@ -591,11 +591,21 @@ We provide two ways to download the executable file of Ollama, one is to downloa
591591

592592
## 百度云盘
593593
### Windows
594-
[Download exe](https://pan.baidu.com/s/1jwolOPTnt48hX_C0f3oUlQ?pwd=awy4) + [Download OpenVINO GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_windows_2025.2.0.0.dev20250320_x86_64.zip)
594+
[Download exe](https://pan.baidu.com/s/10SQLKaGOYIR3NrIhig1xgQ?pwd=8v8w) + [Download OpenVINO GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_windows_2025.2.0.0.dev20250320_x86_64.zip)
595595

596596
### Linux(Ubuntu 22.04)
597-
[Download](https://pan.baidu.com/s/11oTt0UIuuNGNffcC0NLk5g?pwd=1pa3) + [Donwload OpenVINO GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64.tar.gz)
597+
[Download](https://pan.baidu.com/s/1WhzcKRQY_KVLZhy5oa0UIA?pwd=zxgx) + [Donwload OpenVINO GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64.tar.gz)
598598

599+
## Docker
600+
### Linux
601+
We also prepared a Dockerfile to help developers quickly build Docker images: [Dockerfile](./Dockerfile_genai)
602+
```shell
603+
docker build -t ollama_openvino:v1 -f Dockerfile_genai .
604+
```
605+
then
606+
```shell
607+
docker run --rm -it ollama_openvino:v1
608+
```
599609

600610
## Model library
601611
The native Ollama only supports models in the GGUF format, the Ollama-OV invoke OpenVINO GenAI which requires models in the OpenVINO format. Therefore, we have enabled support for OpenVINO model files in Ollama. For public LLMs, you can access and download OpenVINO IR model from HuggingFace or ModelScope:
@@ -630,10 +640,10 @@ The native Ollama only supports models in the GGUF format, the Ollama-OV invoke
630640

631641
Just provide above model link as example for part models, for other LLMs, you can check [OpenVINO GenAI model support list](https://github.com/openvinotoolkit/openvino.genai/blob/master/SUPPORTED_MODELS.md). If you have customized LLM, please follow [model conversion step of GenAI](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#converting-and-compressing-text-generation-model-from-hugging-face-library).
632642

633-
## Performance to reference
643+
<!-- ## Performance to reference
634644
| Model | Ollama-OV with GPU (Driver version:32.0.101.6042) | Ollama-OV with NPU (Driver version:32.0.100.3104) | Device
635645
|-------------------------|---------------|-----------------|-----------------|
636-
| DeepSeek-R1-Distill-Qwen-7B | 19.58 tokens/s | 11.73 tokens/s | Intel(R) Core(TM) Ultra 7 268V 2.20GHz + 32G MEM |
646+
| DeepSeek-R1-Distill-Qwen-7B | 19.58 tokens/s | 11.73 tokens/s | Intel(R) Core(TM) Ultra 7 268V 2.20GHz + 32G MEM | -->
637647

638648

639649

@@ -645,6 +655,7 @@ We added two new parameters to Modelfile based on the original parameters:
645655
| max_new_token | The maximum number of tokens generated by genai (Default: 2048) | int | max_new_token 4096
646656

647657
## Quick start
658+
648659
### Start Ollama
649660

650661
1. First, set GODEGUG=cgocheck=0 env:
@@ -659,7 +670,7 @@ We added two new parameters to Modelfile based on the original parameters:
659670
set GODEBUG=cgocheck=0
660671
```
661672

662-
2. Next, `ollama serve` is used when you want to start ollama without running the desktop application:
673+
2. Next, `ollama serve` is used when you want to start ollama (You must use the Ollama compiled by ollama_ov to start the serve):
663674

664675
```shell
665676
ollama serve
@@ -712,17 +723,26 @@ Let's take [deepseek-ai/DeepSeek-R1-Distill-Qwen-7B](https://hf-mirror.com/deeps
712723
```shell
713724
cd openvino_genai_windows_2025.2.0.0.dev20250320_x86_64
714725
setupvars.bat
715-
716-
set GODEBUG=cgocheck=0
717726
```
718727

719728
5. Create the model in Ollama
720729

721730
```shell
722731
ollama create DeepSeek-R1-Distill-Qwen-7B-int4-ov:v1 -f Modelfile
723732
```
733+
You will see output similar to the following:
734+
```shell
735+
gathering model components
736+
copying file sha256:77acf6474e4cafb67e57fe899264e9ca39a215ad7bb8f5e6b877dcfa0fabf919 100%
737+
using existing layer sha256:77acf6474e4cafb67e57fe899264e9ca39a215ad7bb8f5e6b877dcfa0fabf919
738+
creating new layer sha256:9b345e4ef9f87ebc77c918a4a0cee4a83e8ea78049c0ee2dc1ddd2a337cf7179
739+
creating new layer sha256:ea49523d744c40bc900b4462c43132d1c8a8de5216fa8436cc0e8b3e89dddbe3
740+
creating new layer sha256:b6bf5bcca7a15f0a06e22dcf5f41c6c0925caaab85ec837067ea98b843bf917a
741+
writing manifest
742+
success
743+
```
724744

725-
6. Run the model
745+
6. Run the model
726746

727747
```shell
728748
ollama run DeepSeek-R1-Distill-Qwen-7B-int4-ov:v1
@@ -754,10 +774,6 @@ ollama ps
754774
ollama stop DeepSeek-R1-Distill-Qwen-7B-int4-ov:v1
755775
```
756776

757-
### Start Ollama
758-
759-
`ollama serve` is used when you want to start ollama without running the desktop application.
760-
761777
## Building from source
762778

763779
Install prerequisites:
@@ -782,12 +798,10 @@ Then build and run Ollama from the root directory of the repository:
782798

783799
3. Initialize the GenAI environment
784800

785-
Download GenAI runtime from [GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_windows_2025.2.0.0.dev20250320_x86_64.zip), then extract it to a directory openvino_genai_windows_2025.2.0.0.dev20250320_x86_64.
801+
Download GenAI runtime from [GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_windows_2025.2.0.0.dev20250320_x86_64.zip), then extract it to a directory openvino_genai_windows_2025.2.0.0.dev20250320_x86_64 .
786802
```shell
787803
cd openvino_genai_windows_2025.2.0.0.dev20250320_x86_64
788804
setupvars.bat
789-
790-
set GODEBUG=cgocheck=0
791805
```
792806

793807
4. Setting cgo environment variables
@@ -801,7 +815,7 @@ Then build and run Ollama from the root directory of the repository:
801815
go build -o ollama.exe
802816
```
803817

804-
6. If you don't want to recompile ollama, you can choose to directly use the compiled executable file, and then initialize the genai environment in `step 3` to run ollama directly. The compiled executable file is placed in the `dist` directory: [ollama](dist/windows/ollama.exe).
818+
6. If you don't want to recompile ollama, you can choose to directly use the compiled executable file, and then initialize the genai environment in `step 3` to run ollama directly [ollama](https://drive.google.com/file/d/1iizO9iLhSJGFUu6BgY3EwOchrCyzImUN/view?usp=drive_link).
805819
806820
But if you encounter the error when executing ollama.exe, it is recommended that you recompile from source code.
807821
```shell
@@ -822,12 +836,10 @@ Then build and run Ollama from the root directory of the repository:
822836

823837
3. Initialize the GenAI environment
824838

825-
Download GenAI runtime from [GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_ubuntu20_2025.2.0.0.dev20250320_x86_64.tar.gz), then extract it to a directory openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64.dev20250308_x86_64.
839+
Download GenAI runtime from [GenAI](https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/nightly/2025.2.0.0.dev20250320/openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64.tar.gz), then extract it to a directory openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64.
826840
```shell
827841
cd openvino_genai_ubuntu22_2025.2.0.0.dev20250320_x86_64
828842
source setupvars.sh
829-
830-
export GODEBUG=cgocheck=0
831843
```
832844

833845
4. Setting cgo environment variables
@@ -841,24 +853,44 @@ Then build and run Ollama from the root directory of the repository:
841853
go build -o ollama
842854
```
843855

844-
6. If you don't want to recompile ollama, you can choose to directly use the compiled executable file, and then initialize the genai environment in `step 3` to run ollama directly. The compiled executable file is placed in the `dist` directory: [ollama](dist/linux/ollama).
856+
6. If you don't want to recompile ollama, you can choose to directly use the compiled executable file, and then initialize the genai environment in `step 3` to run ollama directly [ollama](https://drive.google.com/file/d/1HEyZNNCbWSidKNQl4MRsD8FuwEZtdyew/view?usp=drive_link).
845857

846858
If you encounter problems during use, it is recommended to rebuild from source.
847859

848860

849861
### Running local builds
850862

851-
Next, start the server:
863+
1. First, set GODEGUG=cgocheck=0 env:
852864

853-
```shell
854-
ollama serve
855-
```
865+
#### Linux
866+
```shell
867+
export GODEGUG=cgocheck=0
868+
```
856869

857-
Finally, in a separate shell, run a model:
870+
#### Windows
871+
```shell
872+
set GODEBUG=cgocheck=0
873+
```
858874

859-
```shell
860-
ollama run DeepSeek-R1-Distill-Qwen-7B-int4-ov:v1
861-
```
875+
2. Next, start the server:
876+
877+
```shell
878+
ollama serve
879+
```
880+
881+
3. Finally, in a separate shell, run a model:
882+
883+
```shell
884+
ollama run DeepSeek-R1-Distill-Qwen-7B-int4-ov:v1
885+
```
886+
887+
## Community Integrations
888+
### Terminal
889+
890+
- [oterm](https://github.com/ggozad/oterm)
891+
<div style="text-align:center;">
892+
<img src="./images/oterm_demo.gif" alt="Ollama-OV" width="900" height="400">
893+
</div>
862894

863895
## Future Development Plan
864896
Here are some features and improvements planned for future releases:

modules/ollama_openvino/api/types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package api
33
import (
44
"encoding/json"
55
"fmt"
6-
"log"
76
"log/slog"
87
"math"
98
"os"
@@ -691,7 +690,7 @@ func FormatParams(params map[string][]string) (map[string]interface{}, error) {
691690
out := make(map[string]interface{})
692691
// iterate params and set values based on json struct tags
693692
for key, vals := range params {
694-
log.Printf("-----%s: %s", key, vals)
693+
// log.Printf("-----%s: %s", key, vals)
695694
if opt, ok := jsonOpts[key]; !ok {
696695
return nil, fmt.Errorf("unknown parameter '%s'", key)
697696
} else {

modules/ollama_openvino/cmd/cmd.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
9696
if err != nil {
9797
return err
9898
}
99-
log.Printf(modelfile.String())
99+
// log.Printf(modelfile.String())
100100

101101
status := "gathering model components"
102102
spinner := progress.NewSpinner(status)
103103
p.Add(status, spinner)
104104

105-
log.Printf("filepath.Dir(filename): %s", filepath.Dir(filename))
105+
// log.Printf("filepath.Dir(filename): %s", filepath.Dir(filename))
106106
req, err := modelfile.CreateRequest(filepath.Dir(filename))
107107
if err != nil {
108108
return err
@@ -667,9 +667,11 @@ func showInfo(resp *api.ShowResponse, w io.Writer) error {
667667
if resp.ModelInfo != nil {
668668
arch := resp.ModelInfo["general.architecture"].(string)
669669
rows = append(rows, []string{"", "architecture", arch})
670-
rows = append(rows, []string{"", "parameters", format.HumanNumber(uint64(resp.ModelInfo["general.parameter_count"].(float64)))})
671-
rows = append(rows, []string{"", "context length", strconv.FormatFloat(resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64), 'f', -1, 64)})
672-
rows = append(rows, []string{"", "embedding length", strconv.FormatFloat(resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64), 'f', -1, 64)})
670+
if arch != "OpenVINO" {
671+
rows = append(rows, []string{"", "parameters", format.HumanNumber(uint64(resp.ModelInfo["general.parameter_count"].(float64)))})
672+
rows = append(rows, []string{"", "context length", strconv.FormatFloat(resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64), 'f', -1, 64)})
673+
rows = append(rows, []string{"", "embedding length", strconv.FormatFloat(resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64), 'f', -1, 64)})
674+
}
673675
} else {
674676
rows = append(rows, []string{"", "architecture", resp.Details.Family})
675677
rows = append(rows, []string{"", "parameters", resp.Details.ParameterSize})
3.66 MB
Loading
1.75 MB
Loading

modules/ollama_openvino/parser/parser.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io"
10-
"log"
1110
"net/http"
1211
"os"
1312
"os/user"
@@ -48,7 +47,7 @@ func (f Modelfile) CreateRequest(relativeDir string) (*api.CreateRequest, error)
4847
params := make(map[string]any)
4948

5049
for _, c := range f.Commands {
51-
log.Printf("c.Name: %s", c.Name)
50+
// log.Printf("c.Name: %s", c.Name)
5251
switch c.Name {
5352
case "model":
5453
path, err := expandPath(c.Args, relativeDir)

modules/ollama_openvino/server/routes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,9 @@ func GetModelInfo(req api.ShowRequest) (*api.ShowResponse, error) {
10401040
if m.Type == "OpenVINO" {
10411041
resp.ModelType = m.Type
10421042
resp.InferDevice = m.InferDevice
1043+
modelinfo_map := make(map[string]any)
1044+
modelinfo_map["general.architecture"] = m.Type
1045+
resp.ModelInfo = modelinfo_map
10431046
return resp, nil
10441047
} else {
10451048
kvData, err := getKVData(m.ModelPath, req.Verbose)

0 commit comments

Comments
 (0)