Environment Variables: OLLAMA_DEBUG Show additional debug information (e.g. OLLAMA_DEBUG=1) OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) OLLAMA_KEEP_ALIVE The duration that models stay loaded in memory (default "5m") OLLAMA_MAX_LOADED_MODELS Maximum number of loaded models per GPU OLLAMA_MAX_QUEUE Maximum number of queued requests OLLAMA_MODELS The path to the models directory OLLAMA_NUM_PARALLEL Maximum number of parallel requests OLLAMA_NOPRUNE Do not prune model blobs on startup OLLAMA_ORIGINS A comma separated list of allowed origins OLLAMA_SCHED_SPREAD Always schedule model across all GPUs
OLLAMA_FLASH_ATTENTION Enabled flash attention OLLAMA_KV_CACHE_TYPE Quantization typefor the K/V cache (default: f16) OLLAMA_LLM_LIBRARY Set LLM library to bypass autodetection OLLAMA_GPU_OVERHEAD Reserve a portion of VRAM per GPU (bytes) OLLAMA_LOAD_TIMEOUT How long to allow model loads to stall before giving up (default "5m") ---
模型管理
1. 列出所有已下载的模型。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ollama list -h List models
Usage: ollama list [flags]
Aliases: list, ls
Flags: -h, --helphelpfor list
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434)
2. 查看某个模型的详细信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ollama show -h Show information for a model
Usage: ollama show MODEL [flags]
Flags: -h, --helphelpfor show --license Show license of a model --modelfile Show Modelfile of a model --parameters Show parameters of a model --system Show system message of a model --template Show template of a model
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434)
3. 显示正在运行的大模型
1 2 3 4 5 6 7 8 9 10 11
ollama ps -h List running models
Usage: ollama ps [flags]
Flags: -h, --helphelpfor ps
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434)
4. 停止指定的正在运行的模型
1 2 3 4 5 6 7 8 9 10 11
ollama stop -h Stop a running model
Usage: ollama stop MODEL [flags]
Flags: -h, --helphelpfor stop
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434)
5. 删除已下载的大模型
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ollama rm -h
--- Remove a model
Usage: ollama rm MODEL [MODEL...] [flags]
Flags: -h, --helphelpforrm
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) ---
6. 下载大模型
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ollama pull -h
--- Pull a model from a registry
Usage: ollama pull MODEL [flags]
Flags: -h, --helphelpfor pull --insecure Use an insecure registry
Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) ---
运行大模型
尽管我们可以通过第三方的 Web UI 等方式与基于 Ollama 部署的本地大模型进行交互,但通过 run 命令的方式与大模型交互,具有以下的优点:
Flags: --format string Response format (e.g. json) -h, --help help for run --insecure Use an insecure registry --keepalive string Duration to keep a model loaded (e.g. 5m) --nowordwrap Don't wrap words to the next line automatically --verbose Show timings for response Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) OLLAMA_NOHISTORY Do not preserve readline history ---
// stringis the set ofall strings of8-bit bytes, conventionally but not // necessarily representing UTF-8-encoded text. A string may be empty, but // not nil. Values ofstringtype are immutable. typestringstring
type Buffer struct { buf []byte// contents are the bytes buf[off : len(buf)] off int// read at &buf[off], write at &buf[len(buf)] lastRead readOp // last read operation, so that Unread* can work correctly. }
因为 bytes.Buffer 可以持续向 Buffer 尾部写入数据,从 Buffer 头部读取数据,所以 off 字段用来记录读取位置,再利用切片的 cap 特性来知道写入位置,这个不是本次的重点,重点看一下 WriteString 方法是如何拼接字符串的:
1 2 3 4 5 6 7 8
func(b *Buffer) WriteString(s string) (n int, err error) { b.lastRead = opInvalid m, ok := b.tryGrowByReslice(len(s)) if !ok { m = b.grow(len(s)) } returncopy(b.buf[m:], s), nil }
mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ catkin_make source devel/setup.bash
验证安装
打开新终端,运行:
1
roscore
如果看到类似以下输出,说明安装成功:
1 2 3 4 5 6 7
... logging to /home/username/.ros/log/xxx/roslaunch-hostname-xxx.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://hostname:xxx/ ros_comm version 1.14.3