File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -384,9 +384,16 @@ struct clip_ctx {
384384 if (!backend_cpu) {
385385 throw std::runtime_error (" failed to initialize CPU backend" );
386386 }
387- backend = ctx_params.use_gpu
388- ? ggml_backend_init_by_type (GGML_BACKEND_DEVICE_TYPE_GPU, nullptr )
389- : nullptr ;
387+ backend = nullptr ;
388+ auto backend_name = std::getenv (" MTMD_BACKEND_DEVICE" );
389+ if (backend_name != nullptr && ctx_params.use_gpu ) {
390+ backend = ggml_backend_init_by_name (backend_name, nullptr );
391+ }
392+ if (!backend){
393+ backend = ctx_params.use_gpu
394+ ? ggml_backend_init_by_type (GGML_BACKEND_DEVICE_TYPE_GPU, nullptr )
395+ : nullptr ;
396+ }
390397
391398 if (backend) {
392399 LOG_INF (" %s: CLIP using %s backend\n " , __func__, ggml_backend_name (backend));
You can’t perform that action at this time.
0 commit comments