@icyfenix-dmla/cli 2026.4.21-2145 → 2026.5.2-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icyfenix-dmla/cli",
3
- "version": "2026.4.21-2145",
3
+ "version": "2026.5.2-7",
4
4
  "description": "DMLA 沙箱服务命令行工具",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -23,7 +23,7 @@
23
23
  "commander": "^12.1.0",
24
24
  "chalk": "^5.3.0",
25
25
  "enquirer": "^2.4.1",
26
- "dockerode": "^4.0.2",
26
+ "dockerode": "^5.0.0",
27
27
  "express": "^4.21.2",
28
28
  "cors": "^2.8.5",
29
29
  "@icyfenix-dmla/install": "*"
@@ -173,15 +173,70 @@ export async function runDoctor() {
173
173
  console.log(chalk.bold('GPU 驱动'))
174
174
 
175
175
  try {
176
- const output = execSync('nvidia-smi -L', { timeout: 5000, encoding: 'utf8' })
176
+ // 获取完整的 nvidia-smi 输出以解析驱动和 CUDA 版本
177
+ const output = execSync('nvidia-smi', { timeout: 5000, encoding: 'utf8' })
178
+
179
+ // 解析驱动版本
180
+ const driverMatch = output.match(/Driver Version:\s*(\d+\.\d+)/)
181
+ const driverVersion = driverMatch ? driverMatch[1] : null
182
+
183
+ // 解析 CUDA 兼容上限
184
+ const cudaMatch = output.match(/CUDA Version:\s*(\d+\.\d+)/)
185
+ const cudaVersion = cudaMatch ? cudaMatch[1] : null
186
+
177
187
  if (output.includes('GPU')) {
178
188
  console.log(chalk.green(' ✅ NVIDIA GPU 可用'))
189
+
190
+ // 显示驱动版本和 CUDA 兼容上限
191
+ if (driverVersion) {
192
+ console.log(chalk.gray(` 驱动版本: ${driverVersion}`))
193
+ }
194
+ if (cudaVersion) {
195
+ console.log(chalk.gray(` CUDA 兼容上限: ${cudaVersion}`))
196
+ }
197
+
198
+ // GPU 镜像兼容性检查(CUDA 12.8 需要驱动 >= 570)
199
+ const minDriverForGpuImage = 570
200
+ const driverNum = parseFloat(driverVersion || '0')
201
+
202
+ // 显示 GPU 设备信息
179
203
  const lines = output.split('\n').filter(l => l.trim())
180
- lines.forEach(line => console.log(chalk.gray(` ${line.trim()}`)))
204
+ lines.slice(0, 20).forEach(line => {
205
+ if (line.includes('GPU') && !line.includes('Driver Version') && !line.includes('CUDA Version')) {
206
+ console.log(chalk.gray(` ${line.trim()}`))
207
+ }
208
+ })
209
+
210
+ console.log()
211
+
212
+ // GPU 镜像兼容性诊断
213
+ console.log(chalk.bold('GPU 镜像兼容性'))
214
+
215
+ if (gpuExists) {
216
+ if (driverNum >= minDriverForGpuImage) {
217
+ console.log(chalk.green(` ✅ GPU 镜像可用 (驱动 ${driverVersion} >= ${minDriverForGpuImage})`))
218
+ } else {
219
+ console.log(chalk.red(` ❌ GPU 镜像不兼容 (驱动 ${driverVersion} < ${minDriverForGpuImage})`))
220
+ console.log(chalk.yellow(` 💡 CUDA 12.8 需要驱动 >= ${minDriverForGpuImage}`))
221
+ console.log(chalk.yellow(' 解决方案:'))
222
+ console.log(chalk.gray(' 1. 升级 NVIDIA 驱动到 570+ 版本'))
223
+ console.log(chalk.gray(' 2. 或在前端选择 "Run on CPU" 模式'))
224
+ issues.push('GPU 镜像不兼容,请升级驱动或使用 CPU 模式')
225
+ }
226
+ } else if (!gpuExists) {
227
+ console.log(chalk.yellow(' ⚠️ GPU 镜像未安装'))
228
+ if (driverNum >= minDriverForGpuImage) {
229
+ console.log(chalk.green(` ✅ 驱动兼容,可以安装 GPU 镜像`))
230
+ console.log(chalk.gray(' 运行 dmla install --gpu 安装'))
231
+ } else {
232
+ console.log(chalk.yellow(` ⚠️ 驱动 ${driverVersion} 不兼容 CUDA 12.8`))
233
+ console.log(chalk.yellow(` 💡 需要驱动 >= ${minDriverForGpuImage} 才能使用 GPU 镜像`))
234
+ }
235
+ }
181
236
 
182
237
  // 检查 GPU 镜像
183
- if (!gpuExists) {
184
- console.log(chalk.yellow(' 💡 检测到 GPU,建议安装 GPU 镜像'))
238
+ if (!gpuExists && driverNum >= minDriverForGpuImage) {
239
+ console.log(chalk.yellow(' 💡 检测到兼容 GPU,建议安装 GPU 镜像'))
185
240
  issues.push('运行 dmla install --gpu 安装 GPU 镜像')
186
241
  }
187
242
  } else {
@@ -107,6 +107,44 @@ async function checkGPUAvailable() {
107
107
  }
108
108
  }
109
109
 
110
+ /**
111
+ * 检查 GPU 驱动兼容性
112
+ * @returns {Promise<{compatible: boolean, driverVersion: string|null, cudaVersion: string|null}>}
113
+ */
114
+ async function checkGPUDriverCompatibility() {
115
+ const minDriverForCuda128 = 570
116
+
117
+ try {
118
+ const result = await new Promise((resolve, reject) => {
119
+ const proc = spawn('nvidia-smi', [], { timeout: 5000 })
120
+ let output = ''
121
+ proc.stdout.on('data', (data) => output += data.toString())
122
+ proc.stderr.on('data', (data) => output += data.toString())
123
+ proc.on('close', (code) => {
124
+ if (code === 0) resolve(output)
125
+ else reject(new Error('nvidia-smi failed'))
126
+ })
127
+ proc.on('error', reject)
128
+ })
129
+
130
+ // 解析驱动版本
131
+ const driverMatch = result.match(/Driver Version:\s*(\d+\.\d+)/)
132
+ const driverVersion = driverMatch ? driverMatch[1] : null
133
+
134
+ // 解析 CUDA 兼容上限
135
+ const cudaMatch = result.match(/CUDA Version:\s*(\d+\.\d+)/)
136
+ const cudaVersion = cudaMatch ? cudaMatch[1] : null
137
+
138
+ // 判断兼容性
139
+ const driverNum = parseFloat(driverVersion || '0')
140
+ const compatible = driverNum >= minDriverForCuda128
141
+
142
+ return { compatible, driverVersion, cudaVersion }
143
+ } catch {
144
+ return { compatible: false, driverVersion: null, cudaVersion: null }
145
+ }
146
+ }
147
+
110
148
  /**
111
149
  * 检查服务是否运行
112
150
  */
@@ -218,6 +256,22 @@ export async function startServerSync(port, useGpu = false) {
218
256
  return
219
257
  }
220
258
 
259
+ // GPU 驱动兼容性预检
260
+ if (resolvedUseGpu) {
261
+ const driverCheck = await checkGPUDriverCompatibility()
262
+ if (!driverCheck.compatible && driverCheck.driverVersion) {
263
+ console.log(chalk.yellow(`⚠️ GPU 驱动兼容性警告`))
264
+ console.log(chalk.gray(` 当前驱动: ${driverCheck.driverVersion}`))
265
+ console.log(chalk.gray(` CUDA 12.8 需要: 驱动 >= 570`))
266
+ console.log(chalk.yellow(' 解决方案:'))
267
+ console.log(chalk.gray(' 1. 升级 NVIDIA 驾动到 570+ 版本'))
268
+ console.log(chalk.gray(' 2. 使用 CPU 模式: dmla start'))
269
+ console.log()
270
+ console.log(chalk.gray(' 继续启动 GPU 模式(可能会失败)...'))
271
+ console.log()
272
+ }
273
+ }
274
+
221
275
  // 查找服务器入口
222
276
  const actualServerPath = findServerPath()
223
277
  if (!actualServerPath) {
@@ -276,6 +330,22 @@ export async function startServer(port, useGpu = false) {
276
330
  return
277
331
  }
278
332
 
333
+ // GPU 驱动兼容性预检
334
+ if (resolvedUseGpu) {
335
+ const driverCheck = await checkGPUDriverCompatibility()
336
+ if (!driverCheck.compatible && driverCheck.driverVersion) {
337
+ console.log(chalk.yellow(`⚠️ GPU 驱动兼容性警告`))
338
+ console.log(chalk.gray(` 当前驱动: ${driverCheck.driverVersion}`))
339
+ console.log(chalk.gray(` CUDA 12.8 需要: 驱动 >= 570`))
340
+ console.log(chalk.yellow(' 解决方案:'))
341
+ console.log(chalk.gray(' 1. 升级 NVIDIA 驱动到 570+ 版本'))
342
+ console.log(chalk.gray(' 2. 使用 CPU 模式: dmla start'))
343
+ console.log()
344
+ console.log(chalk.gray(' 继续启动 GPU 模式(可能会失败)...'))
345
+ console.log()
346
+ }
347
+ }
348
+
279
349
  // 启动服务
280
350
  console.log(chalk.gray(` 镜像类型: ${imageResolution.message}`))
281
351
  console.log(chalk.gray(' 正在启动...'))