2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

中古GPU(RTX 3060/12GB)でローカルLLM検証-1 ~ 初期設定とGPUコンテナ

Last updated at Posted at 2025-05-04

はじめに

RTX 3060(Ampere / compute 8.6)は中古市場で手頃に入手でき、12GB VRAM がローカルLLM入門にちょうど良い容量です。初回は OSインストール 〜 GPUコンテナ起動 までを確認します。

rtx3060-12gb-1.jpg

検証環境(ハードウェア)

今回、RTX 3060を搭載するPCはやや古いハードウェアですが、ひとまず検証用途としては十分かと思います。RTX 3060は本来PCI Express 4.0 x16に対応していますが、今回のPCのスロットはPCI Express 3.0 x16となります。ただ、3.0と4.0の性能差は実際の運用では大きく影響しないため、検証環境として特に問題はないと判断しました。

項目 内容
GPU NVIDIA GeForce RTX 3060 12 GB(中古)
CPU Intel® Core™ i5-7500 CPU @ 3.40GHz
RAM DDR4 PC4-19200 16GB (8GB x 2)
HDD SATA SSD 500GB
M/B GIGABYTE GA-H170M-D3H (PCI-E 3.0 x16 / PCI-E 2.0 x16)
電源 600W

OSはUbuntu 22.04LTS

Ubuntu 24.04 LTS も CUDA 12.8 対応表に入っていますが、PyTorch/Transformers の安定版 build は Python 3.11 までが十分検証済みだそうです。22.04 はカーネル 5.15 系で DKMS がこなれ、LTS 3 年目でバグも出尽くした感があるとのことです。

1. OS インストール

ISO 取得

ubuntu-22.04.5-live-server-amd64.iso など “Server (minimal)” を推奨。
Universal-USB-Installer にて、USBメモリに書き込みました。

BIOS 設定

Secure Boot を無効。(NVIDIA DKMS が署名されていないためモジュールがロードできないそうです)

OS セットアップ

パッケージ: 最小 を選択(後で Docker が入る程度で OK)。

2. NVIDIA ドライバ導入

sudo apt update
sudo apt upgrade
sudo apt install nvidia-driver-550   # 2025-04 時点で LTS repo 最新
sudo reboot

動作確認:

まずは、OSからGPUが見えていることを確認。

$ sudo nvidia-smi
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.120                Driver Version: 550.120        CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3060        Off |   00000000:01:00.0 Off |                  N/A |
| 30%   27C    P8              5W /  170W |       2MiB /  12288MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

*R550 系は CUDA 12.4/12.5 まで公式サポート。12.8 を使うなら R570 以降が必要です。R570系でCUDA 12.8/12.9は​「まだ “データセンター向けβ” 扱いの可能性あり」となっていたので、R550 + CUDA 12.4で行くことにします。

3. Docker & nvidia-container-toolkit導入

Docker Engine (公式手順を短縮)

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
newgrp docker
docker version
--- 以下、出力
Client: Docker Engine - Community
 Version:           28.1.1
 API version:       1.49
 Go version:        go1.23.8
 Git commit:        4eba377
 Built:             Fri Apr 18 09:52:10 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          28.1.1
  API version:      1.49 (minimum version 1.24)
  Go version:       go1.23.8
  Git commit:       01f442b
  Built:            Fri Apr 18 09:52:10 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker version の出力で Docker Engine が正しく動いていることが確認できました。
次に dockerコンテナでGPUを使えるように NVIDIA Container Toolkit を導入します。

GPU Toolkit

# 1) リポジトリ鍵の登録
distribution=$(. /etc/os-release; echo $ID$VERSION_ID)   # ubuntu22.04
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-archive-keyring.gpg

# 2) リポジトリ追加
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/deb/amd64/ /" |
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

# 3) Toolkit のインストール
sudo apt update
sudo apt install -y nvidia-container-toolkit

# 4) Docker ランタイムに組み込む(nvidia-ctk 1.14+ 推奨)
sudo nvidia-ctk runtime configure --runtime=docker --set-as-default
--- 画面出力例:
INFO[0000] Config file does not exist; using empty config
INFO[0000] Wrote updated config to /etc/docker/daemon.json
INFO[0000] It is recommended that docker daemon be restarted.

# 5) Docker デーモン再起動
sudo systemctl restart docker

# 6)設定確認
docker info | grep -A3 Runtimes
--- 画面出力例:
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: nvidia
 Init Binary: docker-init

コンテナから GPU を見るテスト

docker run --rm --gpus all nvidia/cuda:12.4.0-base-ubuntu22.04 nvidia-smi
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.144.03             Driver Version: 550.144.03     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3060        Off |   00000000:01:00.0 Off |                  N/A |
| 30%   28C    P8              6W /  170W |       2MiB /  12288MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
  • GPUが表示されたので成功
  • driver/library version mismatchと出たらドライバが古いのでアップデートが必要
  • no devices were found の場合は PCIe 側や BIOS で GPU が無効化されていないか確認

無事に Docker コンテナでGPUが使えるところまで設定が出来ました。次回は、いよいよローカルLLMを稼働させていきます。

[次回] 中古GPU(RTX 3060/12GB)でローカルLLM検証-2 ~ llama.cpp で TinyLlama 1.1B を試す

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?