Last Update 2026/04/21
低スペック寄りのPCでローカルLLMを動作させた際の記録です。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
検証用PC
|
OS |
Debian GNU/Linux 12 (bookworm) |
|
CPU |
Intel(R) Core(TM) i5-14400F |
|
GPU |
GeForce RTX 3060 12GB |
|
メモリ |
DDR4 PC4-25600 32GB × 4 |
|
SSD |
crucial P310 CT1000P310SSD8-JP |
構築環境 : Docker + Ollama (特別な設定などは無い状態)
検証用プロンプト
```
### 依頼内容
- コード生成
### 指示
- C言語
- コード以外の出力は不要
- 中括弧スタイルはオールマン
- テストコードを別途生成
### コード仕様
- コマンドラインから整数2つを取得
- [引数1]から[引数2]までをインクリメントして空白区切りで標準出力に出力するコード
- 文字列はmain()ではなく関数で生成
- 戻り値はEXIT_SUCCESSを使用
```
Llama 4 [実測結果一覧へ]
GPU無し
17b-scout-16e-instruct-q4_K_M(3.68TPS)
GPU使用
17b-scout-16e-instruct-q4_K_M(4.28TPS)
コード生成結果の概要
・C言語による生成
・生成出力にバラつき有り(GPU有無で計2回実行の結果)
文字列生成用メモリのサイズの決め方
文字列生成方法が異なる
(1回目) "%d %d ... %d"
(2回目) "%d %d ... %d "
テストケースの内容(ケース数)
・コードの記述スタイルのオールマン指定を無視
・長さ0のフォーマット文字列を使用(1回目のみ)
sprintf(str, "");
gccの-Wformatオプション使用時などで警告発生
・文字列生成関数
mallocにより文字列用メモリを確保
エラー判定無し
インクリメント+空白区切りで文字列を生成
生成した文字列へのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
main()を伴うテストコード
テストケース([2]は2回目実行時のみ生成)
[1] 整数1 < 整数2
[2] 整数1 < 整数2 ただし 整数1が負数
未使用変数の定義が発生
・関数戻り値は stdlib.h の EXIT_*** を使用
テストコードでは「0」を使用
(注) 上記概要は、検証用プロンプトを実測回数分実行した際の結果を使用しています。
LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code_a.c : 実測1回目(GPU無し)に検証用プロンプトにて生成されたコードsample_test_a.c : 実測1回目(GPU無し)に生成されたテストコード
sample_code_b.c : 実測2回目(GPU使用)に検証用プロンプトにて生成されたコード
sample_test_b.c : 実測2回目(GPU使用)に生成されたテストコード
(注)
テストコードには生成コード内の文字列生成関数を追記
【実測1回目(GPU無し)】
$ gcc -Wall -o sample_code_a sample_code_a.c
sample_code_a.c: In function ‘generate_sequence’:
sample_code_a.c:8:28: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
8 | sprintf(sequence + strlen(sequence), " %d", i);
| ^~~~~~
sample_code_a.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code_a.c:8:28: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
8 | sprintf(sequence + strlen(sequence), " %d", i);
| ^~~~~~
sample_code_a.c:8:28: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
$ ./sample_code_a 1 5
1 2 3 4 5
$ ./sample_code_a -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code_a 1 1
1
$ ./sample_code_a 5 1
5
$ gcc -Wall -o sample_test_a sample_test_a.c
sample_test_a.c: In function ‘generate_sequence’:
sample_test_a.c:4:22: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
4 | char* sequence = malloc(1024);
| ^~~~~~
sample_test_a.c:2:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
1 | #include <assert.h>
+++ |+#include <stdlib.h>
2 |
sample_test_a.c:4:22: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
4 | char* sequence = malloc(1024);
| ^~~~~~
sample_test_a.c:4:22: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
sample_test_a.c:5:5: warning: implicit declaration of function ‘sprintf’ [-Wimplicit-function-declaration]
5 | sprintf(sequence, "%d", start);
| ^~~~~~~
sample_test_a.c:2:1: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
1 | #include <assert.h>
+++ |+#include <stdio.h>
2 |
sample_test_a.c:5:5: warning: incompatible implicit declaration of built-in function ‘sprintf’ [-Wbuiltin-declaration-mismatch]
5 | sprintf(sequence, "%d", start);
| ^~~~~~~
sample_test_a.c:5:5: note: include ‘<stdio.h>’ or provide a declaration of ‘sprintf’
sample_test_a.c:7:28: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
7 | sprintf(sequence + strlen(sequence), " %d", i);
| ^~~~~~
sample_test_a.c:2:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
1 | #include <assert.h>
+++ |+#include <string.h>
2 |
sample_test_a.c:7:28: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
7 | sprintf(sequence + strlen(sequence), " %d", i);
| ^~~~~~
sample_test_a.c:7:28: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
In file included from sample_test_a.c:1:
sample_test_a.c: In function ‘main’:
sample_test_a.c:17:12: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
17 | assert(strcmp(sequence1, "1 2 3 4 5") == 0);
| ^~~~~~
sample_test_a.c:17:12: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
sample_test_a.c:18:5: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
18 | free(sequence1);
| ^~~~
sample_test_a.c:18:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
sample_test_a.c:18:5: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
sample_test_a.c:18:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
sample_test_a.c:27:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
27 | printf("All test cases passed.\n");
| ^~~~~~
sample_test_a.c:27:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
sample_test_a.c:27:5: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
sample_test_a.c:27:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
sample_test_a.c:22:9: warning: unused variable ‘argc2’ [-Wunused-variable]
22 | int argc2 = sizeof(argv2) / sizeof(argv2[0]);
| ^~~~~
sample_test_a.c:15:9: warning: unused variable ‘argc1’ [-Wunused-variable]
15 | int argc1 = sizeof(argv1) / sizeof(argv1[0]);
| ^~~~~
$ ./sample_test_a
All test cases passed.
【実測2回目(GPU使用)】
$ gcc -Wall -o sample_code_b sample_code_b.c
sample_code_b.c: In function ‘generate_range_string’:
sample_code_b.c:20:18: warning: zero-length gnu_printf format string [-Wformat-zero-length]
20 | sprintf(str, "");
| ^~
sample_code_b.c:22:23: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
22 | sprintf(str + strlen(str), "%d ", i);
| ^~~~~~
sample_code_b.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code_b.c:22:23: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
22 | sprintf(str + strlen(str), "%d ", i);
| ^~~~~~
sample_code_b.c:22:23: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
$ ./sample_code_b 1 5
1 2 3 4 5
$ ./sample_code_b -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code_b 1 1
1
$ ./sample_code_b 5 1
$ gcc -Wall -o sample_test_b sample_test_b.c
sample_test_b.c: In function ‘generate_range_string’:
sample_test_b.c:7:19: warning: implicit declaration of function ‘snprintf’ [-Wimplicit-function-declaration]
7 | length += snprintf(NULL, 0, "%d ", i);
| ^~~~~~~~
︙
| ^~~~~~~~
sample_test_b.c:7:19: note: include ‘’ or provide a declaration of ‘snprintf’
sample_test_b.c:7:28: error: ‘NULL’ undeclared (first use in this function)
7 | length += snprintf(NULL, 0, "%d ", i);
| ^~~~
sample_test_b.c:2:1: note: ‘NULL’ is defined in header ‘’; did you forget to ‘#include ’?
1 | #include
+++ |+#include
2 |
︙
34 | free(range_str);
| ^~~~
sample_test_b.c:34:5: note: include ‘’ or provide a declaration of ‘free’
sample_test_b.c:34:5: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
sample_test_b.c:34:5: note: include ‘’ or provide a declaration of ‘free’
sample_test_b.c:22:9: warning: unused variable ‘argc’ [-Wunused-variable]
22 | int argc = 3;
| ^~~~
エラー発生によりコンパイル停止
【実測2回目(GPU使用) コード修正後】 コード先頭にstdio.hのインクルードを追加
$ gcc -Wall -o sample_test_b sample_test_b.c
sample_test_b.c: In function ‘generate_range_string’:
sample_test_b.c:12:24: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
12 | char* str = (char*)malloc((length + 1) * sizeof(char));
| ^~~~~~
sample_test_b.c:3:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
2 | #include <assert.h>
+++ |+#include <stdlib.h>
3 |
sample_test_b.c:12:24: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
12 | char* str = (char*)malloc((length + 1) * sizeof(char));
| ^~~~~~
sample_test_b.c:12:24: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
sample_test_b.c:13:18: warning: zero-length gnu_printf format string [-Wformat-zero-length]
13 | sprintf(str, "");
| ^~
sample_test_b.c:15:23: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
15 | sprintf(str + strlen(str), "%d ", i);
| ^~~~~~
sample_test_b.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
2 | #include <assert.h>
+++ |+#include <string.h>
3 |
sample_test_b.c:15:23: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
15 | sprintf(str + strlen(str), "%d ", i);
| ^~~~~~
sample_test_b.c:15:23: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
sample_test_b.c: In function ‘main’:
sample_test_b.c:28:17: warning: implicit declaration of function ‘atoi’ [-Wimplicit-function-declaration]
28 | int start = atoi(argv[1]);
| ^~~~
In file included from sample_test_b.c:2:
sample_test_b.c:33:12: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
33 | assert(strcmp(range_str, expected) == 0);
| ^~~~~~
sample_test_b.c:33:12: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
sample_test_b.c:35:5: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
35 | free(range_str);
| ^~~~
sample_test_b.c:35:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
sample_test_b.c:35:5: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
sample_test_b.c:35:5: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
sample_test_b.c:23:9: warning: unused variable ‘argc’ [-Wunused-variable]
23 | int argc = 3;
| ^~~~
$ ./sample_test_b ← エラーがない場合は出力が無いテストコード
$
17b-scout-16e-instruct-q4_K_M(GPU無し)
Model
architecture llama4
parameters 108.6B
context length 10485760
embedding length 5120
quantization Q4_K_M
2026-04-19
total duration: 2m19.425126775s
load duration: 273.782587ms
prompt eval count: 452 token(s)
prompt eval duration: 36.728061368s
prompt eval rate: 12.31 tokens/s
eval count: 376 token(s)
eval duration: 1m42.202980712s
eval rate: 3.68 tokens/s
17b-scout-16e-instruct-q4_K_M(GPU使用)
Model
architecture llama4
parameters 108.6B
context length 10485760
embedding length 5120
quantization Q4_K_M
2026-04-19
total duration: 1m41.950821333s
load duration: 130.731806ms
prompt eval count: 452 token(s)
prompt eval duration: 5.250810911s
prompt eval rate: 86.08 tokens/s
eval count: 412 token(s)
eval duration: 1m36.357054886s
eval rate: 4.28 tokens/s