@@ -373,7 +373,7 @@ void common_init() {
373373 llama_log_set (common_log_default_callback, NULL );
374374}
375375
376- void common_params_print_info (const common_params & params) {
376+ void common_params_print_info (const common_params & params, bool print_devices ) {
377377#ifdef NDEBUG
378378 const char * build_type = " " ;
379379#else
@@ -382,12 +382,16 @@ void common_params_print_info(const common_params & params) {
382382 LOG_TRC (" %s: build %d (%s) with %s for %s%s\n " , __func__, llama_build_number (), llama_commit (), llama_compiler (), llama_build_target (), build_type);
383383
384384 LOG_INF (" log_info: verbosity = %d (adjust with the `-lv N` CLI arg)\n " , common_log_get_verbosity_thold ());
385- LOG_INF (" device_info:\n " );
386- for (size_t i = 0 ; i < ggml_backend_dev_count (); ++i) {
387- auto * dev = ggml_backend_dev_get (i);
388- size_t free, total;
389- ggml_backend_dev_memory (dev, &free, &total);
390- LOG_INF (" - %-8s: %s (%zu MiB, %zu MiB free)\n " , ggml_backend_dev_name (dev), ggml_backend_dev_description (dev), total / 1024 / 1024 , free / 1024 / 1024 );
385+
386+ // device enumeration creates a primary context on CUDA backends, skip it when the caller does not own any device
387+ if (print_devices) {
388+ LOG_INF (" device_info:\n " );
389+ for (size_t i = 0 ; i < ggml_backend_dev_count (); ++i) {
390+ auto * dev = ggml_backend_dev_get (i);
391+ size_t free, total;
392+ ggml_backend_dev_memory (dev, &free, &total);
393+ LOG_INF (" - %-8s: %s (%zu MiB, %zu MiB free)\n " , ggml_backend_dev_name (dev), ggml_backend_dev_description (dev), total / 1024 / 1024 , free / 1024 / 1024 );
394+ }
391395 }
392396 LOG_INF (" %s\n " , common_params_get_system_info (params).c_str ());
393397}
0 commit comments