| 8 | #include <vector> |
| 9 | |
| 10 | int main(int argc, char ** argv) { |
| 11 | gpt_params params; |
| 12 | |
| 13 | if (argc == 1 || argv[1][0] == '-') { |
| 14 | printf("usage: %s MODEL_PATH [PROMPT] [PARALLEL] [LEN] [N_THREAD] [VRAM_BUDGET] [NGL]\n" , argv[0]); |
| 15 | return 1 ; |
| 16 | } |
| 17 | |
| 18 | // number of parallel batches |
| 19 | int n_parallel = 1; |
| 20 | |
| 21 | // total length of the sequences including the prompt |
| 22 | int n_len = 32; |
| 23 | |
| 24 | // number of layers to offload to the GPU |
| 25 | int n_gpu_layers = 0; |
| 26 | |
| 27 | // vram budget in GiB |
| 28 | double vram_budget = -1; |
| 29 | |
| 30 | if (argc >= 2) { |
| 31 | params.model = argv[1]; |
| 32 | } |
| 33 | |
| 34 | if (argc >= 3) { |
| 35 | params.prompt = argv[2]; |
| 36 | } |
| 37 | |
| 38 | if (argc >= 4) { |
| 39 | n_parallel = std::atoi(argv[3]); |
| 40 | } |
| 41 | |
| 42 | if (argc >= 5) { |
| 43 | n_len = std::atoi(argv[4]); |
| 44 | } |
| 45 | |
| 46 | if (argc >= 6) { |
| 47 | params.n_threads = std::atoi(argv[5]); |
| 48 | } |
| 49 | |
| 50 | if (argc >= 7) { |
| 51 | vram_budget = std::atof(argv[6]); |
| 52 | } |
| 53 | |
| 54 | if (argc >= 8) { |
| 55 | n_gpu_layers = std::atoi(argv[7]); |
| 56 | } |
| 57 | |
| 58 | printf("params: model = %s, prompt = %s, n_parallel = %d, n_len = %d, n_gpu_layers = %d, n_threads = %d, vram_budget = %.2f GiB, reset_gpu_index = true\n", |
| 59 | params.model.c_str(), params.prompt.c_str(), n_parallel, n_len, n_gpu_layers, params.n_threads, vram_budget); |
| 60 | |
| 61 | if (params.prompt.empty()) { |
| 62 | params.prompt = "Hello my name is"; |
| 63 | } |
| 64 | |
| 65 | // init LLM |
| 66 | |
| 67 | llama_backend_init(params.numa); |
nothing calls this directly
no test coverage detected