@@ -76,7 +76,7 @@ function _platformIcon(platform) {
7676 return '' ;
7777}
7878
79- export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , defaultServer : '' } ;
79+ export let _envState = { env : 'none' , envPath : '' , hfToken : '' , hfTokenConfigured : false , hfTokenMasked : '' , gpus : '' , remoteHost : '' , servers : [ ] , modelPaths : [ ] , platform : '' , hostPlatform : '' , defaultServer : '' } ;
8080let _lastCacheHostVal = null ;
8181let _cookbookOpeningSpinners = [ ] ;
8282export function _lastCacheHost ( ) { return _lastCacheHostVal ; }
@@ -213,8 +213,13 @@ function _getPort(hostOrTask) {
213213
214214/** Get platform for a given host (or task object). Returns 'windows', 'termux', 'linux', or '' */
215215export function _getPlatform ( hostOrTask ) {
216- if ( ! hostOrTask ) return _envState . platform || '' ;
217- if ( typeof hostOrTask === 'object' ) return hostOrTask . platform || _getPlatform ( hostOrTask . remoteServerKey || hostOrTask . remoteHost ) ;
216+ if ( hostOrTask === 'local' ) return _envState . hostPlatform || '' ;
217+ if ( ! hostOrTask ) return _envState . remoteHost ? ( _envState . platform || '' ) : ( _envState . hostPlatform || '' ) ;
218+ if ( typeof hostOrTask === 'object' ) {
219+ const taskHost = hostOrTask . remoteServerKey || hostOrTask . remoteHost || '' ;
220+ if ( ! taskHost || taskHost === 'local' ) return _envState . hostPlatform || '' ;
221+ return hostOrTask . platform || _getPlatform ( taskHost ) ;
222+ }
218223 const selected = hostOrTask === _envState . remoteHost ? _selectedServer ( ) : null ;
219224 const srv = selected || _serverByVal ( hostOrTask ) ;
220225 return srv ?. platform || '' ;
@@ -638,7 +643,12 @@ export function _buildServeCmd(f, modelName, backend) {
638643 // GPU list — read from gpus (button strip); fall back to gpu_id for
639644 // backward-compat with older saved presets that pre-date the removal.
640645 const gpuId = ( f . gpus || f . gpu_id || '' ) . toString ( ) . trim ( ) ;
641- const py = _isWindows ( ) ? 'python' : 'python3' ;
646+ const _targetHost = Object . prototype . hasOwnProperty . call ( f , 'host' )
647+ ? String ( f . host || '' ) . trim ( )
648+ : String ( _envState . remoteHost || '' ) . trim ( ) ;
649+ const _isWin = _targetHost ? _isWindows ( _targetHost ) : _isWindows ( 'local' ) ;
650+ const _localWindows = _isWin && ! _targetHost ;
651+ const py = _isWin ? 'python' : 'python3' ;
642652 // CPU-only serve (-ngl 0): drop the GPU-only flags, otherwise the command
643653 // mixes "zero GPU layers" with CUDA unified-memory + flash-attn and fails to
644654 // start (issue #1291). Only affects the ngl=0 path; GPU serving is unchanged.
@@ -660,19 +670,19 @@ export function _buildServeCmd(f, modelName, backend) {
660670 // with misleading prefixes.
661671 const _sb = String ( _hwfitCache ?. system ?. backend || '' ) . toLowerCase ( ) ;
662672 const _hwfitHost = String ( _hwfitCache ?. _scannedHost || '' ) ;
663- const _curHost = String ( _envState . remoteHost || '' ) ;
673+ const _curHost = _targetHost ;
664674 const _isCudaTarget = ( _sb === 'cuda' ) && ( _hwfitHost === _curHost ) ;
665675 const lcPrefix = ( ( ) => {
666676 let p = '' ;
667- if ( f . unified_mem && ! _cpuOnly && ! _isWindows ( ) && _isCudaTarget ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
668- // No GPU env var in CPU mode — `-ngl 0` already disables offload
677+ if ( f . unified_mem && ! _cpuOnly && ( ! _isWin || _localWindows ) && _isCudaTarget ) p += `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 ` ;
678+ // No GPU env var in CPU mode - `-ngl 0` already disables offload
669679 // so CUDA_VISIBLE_DEVICES / HIP_VISIBLE_DEVICES would be misleading
670680 // clutter ("why is CUDA pinned for a CPU run?").
671- if ( ! _isWindows ( ) && ! _cpuOnly ) p += _gpuEnvPrefix ( gpuId ) ;
681+ if ( ( ! _isWin || _localWindows ) && ! _cpuOnly ) p += _gpuEnvPrefix ( gpuId ) ;
672682 return p ;
673683 } ) ( ) ;
674- if ( f . unified_mem && ! _cpuOnly && _isWindows ( ) && _isCudaTarget ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
675- if ( _isWindows ( ) && ! _cpuOnly ) cmd += _gpuEnvPrefix ( gpuId , true ) ;
684+ if ( f . unified_mem && ! _cpuOnly && _isWin && ! _localWindows && _isCudaTarget ) cmd += `$env:GGML_CUDA_ENABLE_UNIFIED_MEMORY="1"; ` ;
685+ if ( _isWin && ! _localWindows && ! _cpuOnly ) cmd += _gpuEnvPrefix ( gpuId , true ) ;
676686 const needsGgufPrelude = / ^ \$ \( \{ \s * f i n d \s / . test ( String ( ggufPath || '' ) ) ;
677687 const modelArg = needsGgufPrelude ? '"$MODEL_FILE"' : `"${ ggufPath } "` ;
678688 // Prefer native llama-server. The backend bootstrap resolves/builds the
@@ -744,11 +754,16 @@ export function _buildServeCmd(f, modelName, backend) {
744754 // llama-cpp-python takes the projector via --clip_model_path.
745755 _lcpExtra += ` --clip_model_path "${ f . _mmproj_path } "` ;
746756 }
747- if ( _isWindows ( ) ) {
748- const _lcpServer = `${ lcPrefix } ${ py } -m llama_cpp.server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } --n_gpu_layers ${ f . ngl || '99' } --n_ctx ${ f . ctx || '8192' } ${ _lcpExtra } ` ;
757+ const _lcServer = `${ lcPrefix } llama-server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } -ngl ${ f . ngl || '99' } -c ${ f . ctx || '8192' } ${ _lcExtra } ` ;
758+ const _lcpServer = `${ lcPrefix } ${ py } -m llama_cpp.server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } --n_gpu_layers ${ f . ngl || '99' } --n_ctx ${ f . ctx || '8192' } ${ _lcpExtra } ` ;
759+ if ( _localWindows ) {
760+ // Local Windows serve is launched through Git Bash, so use the native
761+ // llama-server shape and let PATH resolve the CUDA Release wrapper.
762+ cmd += _lcServer ;
763+ } else if ( _isWin ) {
749764 cmd += _lcpServer ;
750765 } else {
751- cmd += ` ${ lcPrefix } llama-server --model ${ modelArg } --host 0.0.0.0 --port ${ f . port || '8080' } -ngl ${ f . ngl || '99' } -c ${ f . ctx || '8192' } ${ _lcExtra } ` ;
766+ cmd += _lcServer ;
752767 }
753768 if ( needsGgufPrelude ) {
754769 cmd = `MODEL_FILE=${ ggufPath } && { [ -n "$MODEL_FILE" ] && [ -f "$MODEL_FILE" ]; } || { echo "ERROR: No GGUF found on this host"; exit 1; } && ${ cmd } ` ;
@@ -2614,13 +2629,14 @@ function _renderRecipes() {
26142629 const isLocal = ! s . host || s . host . toLowerCase ( ) === 'local' ;
26152630 if ( isLocal ) {
26162631 s . host = '' ;
2632+ s . platform = _envState . hostPlatform || '' ;
26172633 if ( _localSeen ) return false ;
26182634 _localSeen = true ;
26192635 }
26202636 return true ;
26212637 } ) ;
26222638 if ( ! _localSeen ) {
2623- _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
2639+ _es . servers . unshift ( { host : '' , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' , platform : _envState . hostPlatform || '' } ) ;
26242640 }
26252641 if ( _es . remoteHost && ! _es . servers . some ( s => s . host === _es . remoteHost ) ) {
26262642 _es . servers . push ( { host : _es . remoteHost , env : _es . env || 'none' , envPath : _es . envPath || '' , modelDir : '~/.cache/huggingface/hub' } ) ;
0 commit comments