在无法访问huggingface或公网的Linux环境下,使用ollama,搭配qwen模型体验问答能力。
安装ollama
根据官网教程 Linux手动安装
Download the ollama
binary
Ollama is distributed as a self-contained binary. Download it to a directory in your PATH:
1 | # 可以浏览器下载,然后mobaxterm等上传到linux机器 |
Adding Ollama as a startup service (recommended)
Create a user for Ollama:
1 | sudo useradd -r -s /bin/false -m -d /usr/share/ollama ollama |
Create a service file in /etc/systemd/system/ollama.service
:
1 | [Unit] |
Then start the service:
1 | sudo systemctl daemon-reload |
Install CUDA drivers (optional – for Nvidia GPUs) 可选步骤
Download and install CUDA.
Verify that the drivers are installed by running the following command, which should print details about your GPU:
1 | nvidia-smi |
Start Ollama
Start Ollama using systemd
:
1 | sudo systemctl start ollama |
配置ollama
1 | # 1. 配置ollama特有的变量OLLAMA_MODELS记录模型库存储位置,并将其写入环境变量。 |
运行结果
1 | root@ubuntu:/tmp# ollama run qwen0.5b |