0
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?

はじめに

なぜだ。なぜ、unslothの docker.io リポジトリの docker では cuda-toolkit が入ってないんだ。おかげでdevcontainer で llama-cpp をcudaビルドできないじゃないか。

そんな状況を解決するのに丸1日かかってしまいくやしいので、メモしておく。

devcontainer

ファイル配置

----
  |
  |- .devcontaner
  |    |
  |    |- devcontainer.json
  |
  |- src とか

devcontainer.json

unsloth公式のイメージを呼び出して使うことを前提とした。ghcr.io/devcontainers/features/nvidia-cuda:2がエラーになって動かない。

どうするか

devcontainer にrootユーザーで入って、 apt でインストールする。

apt update
apt install cuda-toolkit-12-8

devcontainer.json で "remoteUser":"root" を指定しておくのが肝。

公式の説明では、デフォルトユーザー unsloth / パスワード unsloth なので、 "reomoteUser"を指定せずに開始して、sudo apt install ~ でパスワードを入力すればよさげなのに、sudoでパスワードを受け付けてもらえない。

devcontainer.json
{
	"name": "Gamemaster LLM Development",
	"image": "unsloth/unsloth:2025.10.3-pt2.8.0-cu12.8-llamacpp-integration",
	
	// Features to add to the dev container. More info: https://containers.dev/features.
	"features": {
		"ghcr.io/devcontainers/features/git:1": {},
		"ghcr.io/devcontainers/features/github-cli:1": {},
		// "ghcr.io/devcontainers/features/nvidia-cuda:2": {
		// 	"installToolkit": true,
		// 	"cudaVersion": "12.8"
		// },
		// "ghcr.io/iterative/features/nvtop:1": {},
		"ghcr.io/devcontainers/features/conda:1": {}
	},

	// Container environment variables
	"containerEnv": {
		"USER_PASSWORD": "unsloth"
	},

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	"forwardPorts": [8888],

	"runArgs": ["--gpus", "all"],

	"hostRequirements": {
        "gpu": "optional"
    },
    "remoteEnv": {
        "PATH": "${containerEnv:PATH}:/usr/local/cuda/bin"
    },

	// Configure tool-specific properties.
	"customizations": {
		"vscode": {
			"extensions": [
				"ms-python.python",
				"ms-python.flake8",
				"ms-python.black-formatter",
				"ms-toolsai.jupyter",
				"ms-toolsai.vscode-jupyter-cell-tags",
				"ms-toolsai.vscode-jupyter-slideshow"
			],
			"settings": {
				"python.defaultInterpreterPath": "/opt/conda/bin/python",
				"python.formatting.provider": "black",
				"python.linting.enabled": true,
				"python.linting.flake8Enabled": false,
				"jupyter.askForKernelRestart": false
			}
		}
	},

	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
	"remoteUser": "root",

	// Mount the workspace
	"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
	"workspaceFolder": "/workspace"
}

llamacpp ビルド

workspaceにllamacppのgithubレポジトリをクローンしてビルド

apt-get update
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev -y
git clone https://github.com/ggml-org/llama.cpp
cmake llama.cpp -B llama.cpp/build \
    -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-gguf-split
cp llama.cpp/build/bin/llama-* llama.cp

まとめ

unsloth公式の docker イメージで以下2点が障害となり、cudaを使ったllamacppビルドができなかった。

  1. devcontainer/features/nvidia-cuda:2 が動かない。
  2. unsloth公式の docker イメージをデフォルトユーザーで使う場合において、sudoコマンド使用時デフォルトユーザーパスワードが通らない。

 remoteUser: root を指定して、コンテナをrootユーザーで扱って解決した。

0
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
0
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?