@@ -313,6 +313,100 @@ describe('perform', () => {
313313 expect ( server . labels [ 'gpu' ] ) . toBe ( 'nvidia' ) ;
314314 } ) ;
315315
316+ test ( 'gpu experimental should collect GPU data and find first supported gpu - entry 1 supported' , async ( ) => {
317+ vi . mocked ( configurationRegistry . getExtensionConfiguration ) . mockReturnValue ( {
318+ experimentalGPU : true ,
319+ modelsPath : '' ,
320+ apiPort : 10434 ,
321+ experimentalTuning : false ,
322+ modelUploadDisabled : false ,
323+ showGPUPromotion : false ,
324+ } ) ;
325+
326+ vi . mocked ( gpuManager . collectGPUs ) . mockResolvedValue ( [
327+ {
328+ vram : 1024 ,
329+ model : 'dummy-model' ,
330+ vendor : GPUVendor . UNKNOWN ,
331+ } ,
332+ {
333+ vram : 1024 ,
334+ model : 'nvidia' ,
335+ vendor : GPUVendor . NVIDIA ,
336+ } ,
337+ ] ) ;
338+
339+ const provider = new LlamaCppPython ( taskRegistry , podmanConnection , gpuManager , configurationRegistry ) ;
340+ const server = await provider . perform ( {
341+ port : 8000 ,
342+ image : undefined ,
343+ labels : { } ,
344+ modelsInfo : [ DummyModel ] ,
345+ connection : undefined ,
346+ } ) ;
347+
348+ expect ( containerEngine . createContainer ) . toHaveBeenCalledWith (
349+ DummyImageInfo . engineId ,
350+ expect . objectContaining ( {
351+ Cmd : [
352+ '-c' ,
353+ '/usr/bin/ln -sfn /usr/lib/wsl/lib/* /usr/lib64/ && PATH="${PATH}:/usr/lib/wsl/lib/" && chmod 755 ./run.sh && ./run.sh' ,
354+ ] ,
355+ } ) ,
356+ ) ;
357+ expect ( gpuManager . collectGPUs ) . toHaveBeenCalled ( ) ;
358+ expect ( getImageInfo ) . toHaveBeenCalledWith ( expect . anything ( ) , llamacpp . cuda , expect . any ( Function ) ) ;
359+ expect ( 'gpu' in server . labels ) . toBeTruthy ( ) ;
360+ expect ( server . labels [ 'gpu' ] ) . toBe ( 'nvidia' ) ;
361+ } ) ;
362+
363+ test ( 'gpu experimental should collect GPU data and find first supported gpu - entry 0 supported' , async ( ) => {
364+ vi . mocked ( configurationRegistry . getExtensionConfiguration ) . mockReturnValue ( {
365+ experimentalGPU : true ,
366+ modelsPath : '' ,
367+ apiPort : 10434 ,
368+ experimentalTuning : false ,
369+ modelUploadDisabled : false ,
370+ showGPUPromotion : false ,
371+ } ) ;
372+
373+ vi . mocked ( gpuManager . collectGPUs ) . mockResolvedValue ( [
374+ {
375+ vram : 1024 ,
376+ model : 'nvidia' ,
377+ vendor : GPUVendor . NVIDIA ,
378+ } ,
379+ {
380+ vram : 1024 ,
381+ model : 'dummy-model' ,
382+ vendor : GPUVendor . UNKNOWN ,
383+ } ,
384+ ] ) ;
385+
386+ const provider = new LlamaCppPython ( taskRegistry , podmanConnection , gpuManager , configurationRegistry ) ;
387+ const server = await provider . perform ( {
388+ port : 8000 ,
389+ image : undefined ,
390+ labels : { } ,
391+ modelsInfo : [ DummyModel ] ,
392+ connection : undefined ,
393+ } ) ;
394+
395+ expect ( containerEngine . createContainer ) . toHaveBeenCalledWith (
396+ DummyImageInfo . engineId ,
397+ expect . objectContaining ( {
398+ Cmd : [
399+ '-c' ,
400+ '/usr/bin/ln -sfn /usr/lib/wsl/lib/* /usr/lib64/ && PATH="${PATH}:/usr/lib/wsl/lib/" && chmod 755 ./run.sh && ./run.sh' ,
401+ ] ,
402+ } ) ,
403+ ) ;
404+ expect ( gpuManager . collectGPUs ) . toHaveBeenCalled ( ) ;
405+ expect ( getImageInfo ) . toHaveBeenCalledWith ( expect . anything ( ) , llamacpp . cuda , expect . any ( Function ) ) ;
406+ expect ( 'gpu' in server . labels ) . toBeTruthy ( ) ;
407+ expect ( server . labels [ 'gpu' ] ) . toBe ( 'nvidia' ) ;
408+ } ) ;
409+
316410 test ( 'unknown gpu on unsupported vmtype should not provide gpu labels' , async ( ) => {
317411 vi . mocked ( configurationRegistry . getExtensionConfiguration ) . mockReturnValue ( {
318412 experimentalGPU : true ,
0 commit comments