@@ -615,6 +615,25 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
615615 ucs_sys_dev_distance_t dist ;
616616 int i , num_gpus ;
617617
618+ /*
619+ * Save the result of peermem driver check in a global flag to avoid
620+ * printing diag message for each MD.
621+ */
622+ if (peermem_loaded == -1 ) {
623+ peermem_loaded = !!(md -> super .reg_mem_types &
624+ UCS_BIT (UCS_MEMORY_TYPE_CUDA ));
625+ if (peermem_loaded == 0 ) {
626+ ucs_diag ("GDAKI not supported, please load "
627+ "Nvidia peermem driver by running "
628+ "\"modprobe nvidia_peermem\"" );
629+ }
630+ }
631+
632+ if (peermem_loaded == 0 ) {
633+ status = UCS_ERR_NO_DEVICE ;
634+ goto out ;
635+ }
636+
618637 status = UCT_CUDADRV_FUNC_LOG_ERR (cuDeviceGetCount (& num_gpus ));
619638 if (status != UCS_OK ) {
620639 return status ;
@@ -652,25 +671,6 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
652671 goto err ;
653672 }
654673
655- /*
656- * Save the result of peermem driver check in a global flag to avoid
657- * printing diag message for each GPU and MD.
658- */
659- if (peermem_loaded == -1 ) {
660- peermem_loaded = !!(md -> super .reg_mem_types &
661- UCS_BIT (UCS_MEMORY_TYPE_CUDA ));
662- if (peermem_loaded == 0 ) {
663- ucs_diag ("GDAKI not supported, please load "
664- "Nvidia peermem driver by running "
665- "\"modprobe nvidia_peermem\"" );
666- }
667- }
668-
669- if (peermem_loaded == 0 ) {
670- status = UCS_ERR_NO_DEVICE ;
671- goto err ;
672- }
673-
674674 uct_cuda_base_get_sys_dev (device , & dev );
675675 status = ucs_topo_get_distance (dev , md -> super .dev .sys_dev , & dist );
676676 if (status != UCS_OK ) {
@@ -697,6 +697,7 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
697697
698698err :
699699 ucs_free (tl_devices );
700+ out :
700701 return status ;
701702}
702703
0 commit comments