Skip to content

Commit c61ae20

Browse files
rgerganovslaren
andauthored
rpc : update documentation (#16441)
Update the README file to match the newly added functionality of exposing multiple devices from a single server. Co-authored-by: Diego Devesa <[email protected]>
1 parent 0123ff3 commit c61ae20

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

tools/rpc/README.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
> This example and the RPC backend are currently in a proof-of-concept development stage. As such, the functionality is fragile and
55
> insecure. **Never run the RPC server on an open network or in a sensitive environment!**
66
7-
The `rpc-server` allows running `ggml` backend on a remote host.
7+
The `rpc-server` allows exposing `ggml` devices on a remote host.
88
The RPC backend communicates with one or several instances of `rpc-server` and offloads computations to them.
99
This can be used for distributed LLM inference with `llama.cpp` in the following way:
1010

@@ -14,28 +14,34 @@ flowchart TD
1414
rpcb<-->|TCP|srvb
1515
rpcb<-.->|TCP|srvn
1616
subgraph hostn[Host N]
17-
srvn[rpc-server]<-.->backend3["Backend (CUDA,Metal,etc.)"]
17+
srvn[rpc-server]<-.->dev4["CUDA0"]
18+
srvn[rpc-server]<-.->dev5["CPU"]
1819
end
1920
subgraph hostb[Host B]
20-
srvb[rpc-server]<-->backend2["Backend (CUDA,Metal,etc.)"]
21+
srvb[rpc-server]<-->dev3["Metal"]
2122
end
2223
subgraph hosta[Host A]
23-
srva[rpc-server]<-->backend["Backend (CUDA,Metal,etc.)"]
24+
srva[rpc-server]<-->dev["CUDA0"]
25+
srva[rpc-server]<-->dev2["CUDA1"]
2426
end
2527
subgraph host[Main Host]
26-
local["Backend (CUDA,Metal,etc.)"]<-->ggml[llama-cli]
28+
local["Local devices"]<-->ggml[llama-cli]
2729
ggml[llama-cli]<-->rpcb[RPC backend]
2830
end
2931
style hostn stroke:#66,stroke-width:2px,stroke-dasharray: 5 5
32+
classDef devcls fill:#5B9BD5
33+
class local,dev,dev2,dev3,dev4,dev5 devcls
3034
```
3135

32-
Each host can run a different backend, e.g. one with CUDA and another with Metal.
33-
You can also run multiple `rpc-server` instances on the same host, each with a different backend.
36+
By default, `rpc-server` exposes all available accelerator devices on the host.
37+
If there are no accelerators, it exposes a single `CPU` device.
3438

3539
## Usage
3640

37-
On each host, build the corresponding backend with `cmake` and add `-DGGML_RPC=ON` to the build options.
38-
For example, to build the CUDA backend with RPC support:
41+
### Remote hosts
42+
43+
On each remote host, build the backends for each accelerator by adding `-DGGML_RPC=ON` to the build options.
44+
For example, to build the `rpc-server` with support for CUDA accelerators:
3945

4046
```bash
4147
mkdir build-rpc-cuda
@@ -44,33 +50,38 @@ cmake .. -DGGML_CUDA=ON -DGGML_RPC=ON
4450
cmake --build . --config Release
4551
```
4652

47-
Then, start the `rpc-server` with the backend:
53+
When started, the `rpc-server` will detect and expose all available `CUDA` devices:
4854

4955
```bash
50-
$ bin/rpc-server -p 50052
51-
create_backend: using CUDA backend
52-
ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
53-
ggml_cuda_init: CUDA_USE_TENSOR_CORES: yes
56+
$ bin/rpc-server
57+
ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no
58+
ggml_cuda_init: GGML_CUDA_FORCE_CUBLAS: no
5459
ggml_cuda_init: found 1 CUDA devices:
55-
Device 0: NVIDIA T1200 Laptop GPU, compute capability 7.5, VMM: yes
56-
Starting RPC server on 0.0.0.0:50052
60+
Device 0: NVIDIA GeForce RTX 5090, compute capability 12.0, VMM: yes
61+
Starting RPC server v3.0.0
62+
endpoint : 127.0.0.1:50052
63+
local cache : n/a
64+
Devices:
65+
CUDA0: NVIDIA GeForce RTX 5090 (32109 MiB, 31588 MiB free)
5766
```
5867

59-
When using the CUDA backend, you can specify the device with the `CUDA_VISIBLE_DEVICES` environment variable, e.g.:
68+
You can control the set of exposed CUDA devices with the `CUDA_VISIBLE_DEVICES` environment variable or the `--device` command line option. The following two commands have the same effect:
6069
```bash
6170
$ CUDA_VISIBLE_DEVICES=0 bin/rpc-server -p 50052
71+
$ bin/rpc-server --device CUDA0 -p 50052
6272
```
63-
This way you can run multiple `rpc-server` instances on the same host, each with a different CUDA device.
6473

74+
### Main host
6575

66-
On the main host build `llama.cpp` for the local backend and add `-DGGML_RPC=ON` to the build options.
67-
Finally, when running `llama-cli`, use the `--rpc` option to specify the host and port of each `rpc-server`:
76+
On the main host build `llama.cpp` with the backends for the local devices and add `-DGGML_RPC=ON` to the build options.
77+
Finally, when running `llama-cli` or `llama-server`, use the `--rpc` option to specify the host and port of each `rpc-server`:
6878

6979
```bash
70-
$ bin/llama-cli -m ../models/tinyllama-1b/ggml-model-f16.gguf -p "Hello, my name is" --repeat-penalty 1.0 -n 64 --rpc 192.168.88.10:50052,192.168.88.11:50052 -ngl 99
80+
$ llama-cli -hf ggml-org/gemma-3-1b-it-GGUF -ngl 99 --rpc 192.168.88.10:50052,192.168.88.11:50052
7181
```
7282

73-
This way you can offload model layers to both local and remote devices.
83+
By default, llama.cpp distributes model weights and the KV cache across all available devices -- both local and remote -- in proportion to each device's available memory.
84+
You can override this behavior with the `--tensor-split` option and set custom proportions when splitting tensor data across devices.
7485

7586
### Local cache
7687

@@ -83,3 +94,11 @@ $ bin/rpc-server -c
8394
```
8495

8596
By default, the cache is stored in the `$HOME/.cache/llama.cpp/rpc` directory and can be controlled via the `LLAMA_CACHE` environment variable.
97+
98+
### Troubleshooting
99+
100+
Use the `GGML_RPC_DEBUG` environment variable to enable debug messages from `rpc-server`:
101+
```bash
102+
$ GGML_RPC_DEBUG=1 bin/rpc-server
103+
```
104+

0 commit comments

Comments
 (0)