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?

DGX SparkでCodex CLIを使ってみる

0
Posted at

はじめに

  • 最近Claude Codeが人気。
  • 私はOpenAIのPlusプランで毎月3,000円を課金しているから、まずはCodexを試してみよう。

うちの環境

  • mac miniからDGX SparkにSSH接続

Codexのインストール

DGX SparkにてCodexをインストール。

sudo apt update
sudo apt install -y curl

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
source ~/.bashrc

nvm install --lts
nvm use --lts

node -v
npm -v

npm install -g @openai/codex
codex --version

Codex CLIの起動

Codexを起動してみる。

mkdir -p ~/repos/codex-first-test
cd ~/repos/codex-first-test
git init
codex

信頼していいかと聞かれるので、YESを選ぶ。

> You are in /home/hoshiba/repos/codex-first-test

  Do you trust the contents of this directory? Working with untrusted contents
  comes with higher risk of prompt injection. Trusting the directory allows
  project-local config, hooks, and exec policies to load.

› 1. Yes, continue
  2. No, quit

  Press enter to continue

モデルは最新のgpt-5.5が採用されている。
スクリーンショット 2026-05-06 7.17.29.png

最初に日本語で認証確認してみる。

› こんにちは。認証確認のためのテストです。
  ファイル編集やコマンド実行は行わず、日本語で1行だけ返答してください。

ちゃんと応答が確認できた!
image.png

Codex CLIの実行

早速お願いしてみる。
日本語でやってほしいことを書くだけ。

このディレクトリに、DGX Sparkの簡単な診断CLIツールをPythonで作ってください。

要件:
- main.py を作る
- README.md を作る
- requirements.txt を作る
- ホスト名、OS情報、Pythonバージョンを表示する
- 可能なら nvidia-smi を実行してGPU情報を表示する
- 実行結果を JSON ファイルにも保存する
- ~/data 配下は読まない、変更しない
- まずは最小構成でよい

色々と動いたあと、私に承認を求めてきた。1で。

  Would you like to make the following edits?
 
  Reason: command failed; retry without sandbox?
 
› 1. Yes, proceed (y)
  2. Yes, and don't ask again for these files (a)
  3. No, and tell Codex what to do differently (esc)

そしたら、ファイルを追加したよ、という報告と、また次に進めてよいかという承認を求めてきた。
うん、ホウレンソウがしっかりできるかわいいやつだ!
もちろん進めていいよ!

• 3ファイルを追加しました。次に構文と実行を確認して、JSON保存まで通るか見ます。出力先はリポ
  ジトリ内の一時的な診断JSONにします。

• Running python3 -m py_compile main.py

• Running python3 main.py --output test_diagnostics.json

 
  Would you like to run the following command?
 
  Reason: 追加した Python ファイルの構文確認を通常権限で実行してよいですか?
 
  $ python3 -m py_compile main.py
 
› 1. Yes, proceed (y)
  2. Yes, and don't ask again for commands that start with `python3 -m py_compile` (p)
  3. No, and tell Codex what to do differently (esc)

なんだかんだで、ちゃんとコードはできたし、動作もした。

• 実行しました。結果は正常終了です。

  出力先:

  - dgx_spark_diagnostics.json

  主な結果:

  - Hostname: spark-05ae
  - OS: Linux-6.17.0-1014-nvidia-aarch64-with-glibc2.39
  - Python: 3.12.3 (CPython)
  - GPU: NVIDIA GB10, driver 580.142, temperature 37 C

まとめ

  • なるほど、私とcodexが会話しながらコードの作成、実行、修正をやっていくんだな。- これまでChatGPTと会話しながら、私がコードやら実行結果やらをコピペしていたんだけど、それよりもずっと便利だ!
  • 超高性能のgpt5.5が使われている。でも利用制限があるだろうし、次はローカルLLMに差し替えて試してみたい。
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?