diff --git a/src/main/kotlin/service/LlamaServerManager.kt b/src/main/kotlin/service/LlamaServerManager.kt index 92998eb..4d5dab6 100644 --- a/src/main/kotlin/service/LlamaServerManager.kt +++ b/src/main/kotlin/service/LlamaServerManager.kt @@ -24,20 +24,11 @@ object LlamaServerManager { if (processes.containsKey(port) || modelPath.isBlank()) return val os = System.getProperty("os.name").lowercase() val arch = System.getProperty("os.arch").lowercase() + val isWin = os.contains("win") val (nGpuLayers, threads) = when { - // M3 맥: 통합 메모리 활용 최적 (99레이어, 성능코어 위주 8스레드) - os.contains("mac") && (arch.contains("arm64") || arch.contains("aarch64")) -> { - 99 to 8 - } - // 윈도우 NUC: Core Ultra 7은 코어가 많으므로 스레드 상향 (OpenVINO 사용 시 nGpu 조정 가능) - os.contains("win") -> { - // NUC 15 Pro (Core Ultra 7 155H)는 16코어 22스레드이므로 12~14 권장 - 40 to 12 - } - // 인텔 맥 2017: 16GB 램 한계로 인해 CPU 위주 설정 권장 - else -> { - 0 to 4 // 쿼드코어 모델일 가능성이 높음 - } + os.contains("mac") && (arch.contains("arm64") || arch.contains("aarch64")) -> 99 to 8 + isWin -> 40 to 12 // NUC Core Ultra 7: GPU 레이어 40 내외, 스레드 12 권장 + else -> 0 to 4 // 인텔 맥 2017 등 } val command = listOf( @@ -50,11 +41,24 @@ object LlamaServerManager { "--embedding" ) - scope.launch { try { val pb = ProcessBuilder(command) + // 2. 윈도우 Vulkan 환경 변수 설정 + if (isWin && binPath.contains("win-x64")) { + val env = pb.environment() + // 특정 GPU 선택 (내장 GPU가 여러 개일 경우) + // env["GGML_VULKAN_DEVICE"] = "0" + + // DLL 로드 경로 강제 지정 (bin 폴더 내 dll 참조) + val libraryPath = File(binPath).parentFile.absolutePath + val currentPath = System.getenv("PATH") ?: "" + env["PATH"] = "$libraryPath;$currentPath" + + println("🔧 [Vulkan] 환경 변수 설정 완료: $libraryPath") + } + pb.redirectErrorStream(true) File(binPath).setExecutable(true)