lib/Rex/GPU/NVIDIA/Setup.pm

filter: Statementstmt 96.8% 429 / 443 Branchbran 89.5% 179 / 200 Conditioncond 77.1% 125 / 162 MC/DCmcdc 59.3% 54 / 91 Subroutinesub 86.5% 71 / 82 Podpod 97.9% 47 / 48 totaltotal 88.2% 905 / 1026 CC 176 SCAR 19.4
CC
176
Cov
91%
adopt
17.0
retrofit_fabric_manager
16.0
resolve_plan
11.6
CRAP 7.0
« lib/Rex/GPU/Detect/Sysfs.pm ↑ Summary blib/lib/Rex/GPU/Detect.pm »
1 # ABSTRACT: Base class of the per-distro NVIDIA driver setups (experimental)
2  
3 package Rex::GPU::NVIDIA::Setup;
4 36 our $VERSION = '0.005';
5 36 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 36 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 36 ▶use Rex::Commands::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 36 ▶use Rex::Commands::Gather ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 36 ▶use Rex::Commands::Pkg ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 36 ▶use Rex::Commands::Run ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 36 ▶use Rex::Logger ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 36 ▶use Rex::GPU::NVIDIA::Requirement ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 36 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 36 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # No `use utf8` here, on purpose: the die messages carry UTF-8 em dashes as
17 # byte strings exactly like Rex::GPU::NVIDIA always emitted them.
18  
19  
20 36 has gpu => ( is => 'ro' );
21 36 has gpus => ( is => 'lazy', writer => '_set_gpus' );
22  
23 116 ▶sub _build_gpus {
Subroutine _build_gpus: called CC=2 SCAR=6.9
24 116 my ( $self ) = @_;
25 116 ▶ return defined $self->gpu ? [ $self->gpu ] : [];
Branch: 1 branch
BranchTrueFalseTotal
defined $self->gpu ? : 88 28 116
26 }
27  
28 775 ▶sub BUILD {
Subroutine BUILD: called CC=9 SCAR=22.0
Pod undocumented
29 775 my ( $self, $args ) = @_;
30 croak __PACKAGE__.'->new: pass gpu or gpus, not both'
31 775 ▶ if defined $args->{gpu} && defined $args->{gpus};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"gpu"} and defined $args->{"gpus"} 1 774 775
Condition100%3/3
defined $args->{"gpu"} and defined $args->{"gpus"}
!ll&&!rl&&r
685891
MC/DC100%2/2
defined $args->{"gpu"} and defined $args->{"gpus"}
defined $args->{"gpu"} defined $args->{"gpus"}
Truth table100%3/3
A and B
A= defined $args->{"gpu"}B= defined $args->{"gpus"}
ABresult
0X0
100
111
32 croak __PACKAGE__.'->new: gpus must be an arrayref of GPU hashrefs'
33 774 ▶ if defined $args->{gpus} && ref $args->{gpus} ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"gpus"} and ref $args->{"gpus"} ne "ARRAY" 1 773 774
Condition100%3/3
defined $args->{"gpus"} and ref $args->{"gpus"} ne "ARRAY"
!ll&&!rl&&r
1865871
MC/DC100%2/2
defined $args->{"gpus"} and ref $args->{"gpus"} ne "ARRAY"
defined $args->{"gpus"} ref $args->{"gpus"} ne "ARRAY"
Truth table100%3/3
A and B
A= defined $args->{"gpus"}B= ref $args->{"gpus"} ne "ARRAY"
ABresult
0X0
100
111
34 croak __PACKAGE__.'->new: nvswitches must be an arrayref'
35 773 ▶ if defined $args->{nvswitches} && ref $args->{nvswitches} ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"nvswitches"} and ref $args->{"nvswitches"} ne "ARRAY" 1 772 773
Condition100%3/3
defined $args->{"nvswitches"} and ref $args->{"nvswitches"} ne "ARRAY"
!ll&&!rl&&r
734381
MC/DC100%2/2
defined $args->{"nvswitches"} and ref $args->{"nvswitches"} ne "ARRAY"
defined $args->{"nvswitches"} ref $args->{"nvswitches"} ne "ARRAY"
Truth table100%3/3
A and B
A= defined $args->{"nvswitches"}B= ref $args->{"nvswitches"} ne "ARRAY"
ABresult
0X0
100
111
36 772 ▶ $self->_check_gpus($args->{gpus} // [ defined $args->{gpu} ? $args->{gpu} : () ]);
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'gpu'} ? : 89 96 185
Condition100%2/2
$args->{"gpus"} // [defined $args->{"gpu"} ? $args->{"gpu"} : ()]
l!l
587185
MC/DC100%1/1
$args->{"gpus"} // [defined $args->{"gpu"} ? $args->{"gpu"} : ()]
$args->{"gpus"}
Truth table100%2/2
A
A= $args->{"gpus"}
Aresult
11
00
37 }
38  
39 # A device_id that is there but not four hex digits ("0x2b85" from sysfs,
40 # "2b85\n" from a cat) would make Requirement->from_gpu see an unknown GPU:
41 # no Kepler refusal, no open module for Blackwell. Croak instead (karr #42).
42 783 ▶sub _check_gpus {
Subroutine _check_gpus: called CC=5 SCAR=16.1
43 783 my ( $self, $gpus ) = @_;
44 783 for my $gpu (grep { ref $_ eq 'HASH' } @$gpus) {
45 913 my $id = $gpu->{device_id};
46 913 ▶ next if !defined $id || $id =~ /\A[0-9a-f]{4}\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $id or $id =~ /\A[0-9a-f]{4}\z/i 905 8 913
Condition100%3/3
not defined $id or $id =~ /\A[0-9a-f]{4}\z/i
l!l&&r!l&&!r
49018
MC/DC100%2/2
not defined $id or $id =~ /\A[0-9a-f]{4}\z/i
not defined $id $id =~ /\A[0-9a-f]{4}\z/i
Truth table100%3/3
not(A) or B
A= not defined $idB= $id =~ /\A[0-9a-f]{4}\z/i
ABresult
1X1
011
000
47 8 ▶ croak "NVIDIA GPU '".( $gpu->{name} // 'unknown' )."': device_id '".$id."' is not "
Condition100%2/2
$gpu->{"name"} // "unknown"
l!l
62
MC/DC100%1/1
$gpu->{"name"} // "unknown"
$gpu->{"name"}
Truth table100%2/2
A
A= $gpu->{"name"}
Aresult
11
00
48 .'a PCI device ID of four hex digits, e.g. 2b85 (no 0x, no newline). No driver '
49 .'package was installed and no package source was added';
50 }
51 775 return;
52 }
53  
54  
55 36 has nvswitches => ( is => 'lazy', writer => '_set_nvswitches' );
56  
57 511 ▶sub _build_nvswitches { [] }
Subroutine _build_nvswitches: called CC=1 SCAR=0.0
58  
59 2019 ▶sub fabric_manager_needed {
Subroutine fabric_manager_needed: called CC=2 SCAR=6.9
Pod documented
60 2019 my ( $self ) = @_;
61 2019 ▶ return 1 if grep { ref $_ eq 'HASH' } @{ $self->nvswitches };
Branch: 1 branch
BranchTrueFalseTotal
if grep {ref $_ eq "HASH";} @{$self->nvswitches;} 93 1926 2019
62 1926 return $self->nvlink_fabric_needed;
63 }
64  
65 87 ▶sub fabric_label {
Subroutine fabric_label: called CC=2 SCAR=6.9
Pod documented
66 87 my ( $self ) = @_;
67 87 ▶ return ( grep { ref $_ eq 'HASH' } @{ $self->nvswitches } )
Branch: 1 branch
BranchTrueFalseTotal
grep({ref $_ eq 'HASH';} @{$self->nvswitches;}) ? : 61 26 87
68 ? 'NVSwitch' : 'HGX B200/B300 NVLink fabric';
69 }
70  
71  
72 3586 ▶sub nvlink_platform_ids {
Subroutine nvlink_platform_ids: called CC=1 SCAR=0.0
Pod documented
73 return (
74 3586 '2901' => 'hgx-nvlink5', # B200
75 '2909' => 'hgx-nvlink5', # B200
76 '3182' => 'hgx-nvlink5', # B300 SXM6 AC
77 '2941' => 'nvl72', # GB200
78 '31c2' => 'nvl72', # GB300
79 '31c3' => 'nvl72' # GB300
80 );
81 }
82  
83 3588 ▶sub nvlink_platforms {
Subroutine nvlink_platforms: called CC=2 SCAR=6.9
Pod documented
84 3588 my ( $self ) = @_;
85 3588 my %platform = $self->nvlink_platform_ids;
86 1011 my %seen = map { $_ => 1 }
87 4854 grep { defined }
88 4854 ▶ map { $platform{ lc( $_->{device_id} // '' ) } }
Condition100%2/2
$_->{"device_id"} // ""
l!l
484014
MC/DC100%1/1
$_->{"device_id"} // ""
$_->{"device_id"}
Truth table100%2/2
A
A= $_->{"device_id"}
Aresult
11
00
89 3588 grep { ref $_ eq 'HASH' } @{ $self->gpus };
90 3588 return sort keys %seen;
91 }
92  
93 3166 ▶sub nvlink_fabric_needed {
Subroutine nvlink_fabric_needed: called CC=2 SCAR=6.9
Pod documented
94 3166 my ( $self ) = @_;
95 3166 ▶ return ( grep { $_ eq 'hgx-nvlink5' } $self->nvlink_platforms ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq 'hgx-nvlink5';} $self->nvlink_platforms) ? : 128 3038 3166
96 }
97  
98 # extra_requirement may be given as a plain hashref; it becomes an object of
99 # the class's requirement_class here, so a typo croaks at construction -- on
100 # every host, not only on one that gets as far as plan.
101 779 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
102 779 my ( $orig, $class, @args ) = @_;
103 779 my $args = $class->$orig(@args);
104 $args->{extra_requirement} = $class->_coerce_requirement($args->{extra_requirement})
105 779 ▶ if defined $args->{extra_requirement};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"extra_requirement"} 13 766 779
106 775 return $args;
107 36 };
108  
109  
110 36 has requirement => ( is => 'lazy', predicate => '_has_requirement' );
111  
112 36 has extra_requirement => ( is => 'ro', writer => '_set_extra_requirement' );
113  
114 1312 ▶sub requirement_class { 'Rex::GPU::NVIDIA::Requirement' }
Subroutine requirement_class: called CC=1 SCAR=0.0
Pod documented
115  
116 529 ▶sub _build_requirement {
Subroutine _build_requirement: called CC=6 SCAR=17.9
117 529 my ( $self ) = @_;
118 529 my $class = $self->requirement_class;
119 529 my $extra = $self->extra_requirement;
120 529 my @gpus = grep { ref $_ eq 'HASH' } @{ $self->gpus };
121 529 ▶ return $extra // $class->new unless @gpus;
Branch: 1 branch
BranchTrueFalseTotal
unless @gpus 35 494 529
Condition66%2/3
$extra // $class->new
l!l&&r!l&&!r
2330
MC/DC0%0/2
$extra // $class->new
$extra $class->new
Truth table66%2/3
A // B
A= $extraB= $class->new
ABresult
1X1
011
000
122 494 my @reqs = map { $class->from_gpu($_) } @gpus;
123 494 ▶ if ( my @conflicts = $class->conflicts(@reqs) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@conflicts) = $class->conflicts(@reqs)) 24 470 494
124 24 die 'No single NVIDIA driver supports all GPUs on this host: '
125 .join('; ', @conflicts).'. No driver package was installed and no package '
126 .'source was added. Install the '
127 ."driver yourself; once `nvidia-smi -L` lists the GPUs and libcuda.so.1 is in "
128 ."the linker cache, install_driver skips the driver step\n";
129 }
130 470 my $gpu_req = $class->intersect(@reqs);
131 470 ▶ return $gpu_req unless $extra;
Branch: 1 branch
BranchTrueFalseTotal
unless $extra 464 6 470
132 # The user's requirement only tightens (karr #34): a conflict with what the
133 # GPUs need dies here, in plan, before anything on the host is changed.
134 6 ▶ if ( my @conflicts = $class->conflicts($gpu_req, $extra) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@conflicts) = $class->conflicts($gpu_req, $extra)) 2 4 6
135 2 die 'No NVIDIA driver meets both what the GPUs need and '.$extra->who.' ('
136 .$extra->describe.'): '.join('; ', @conflicts).'. No driver package was '
137 .'installed and no package source was added. '
138 ."Loosen the requirement, or install the driver yourself\n";
139 }
140 4 return $class->intersect($gpu_req, $extra);
141 }
142  
143 36 my %REQUIREMENT_KEY = map { $_ => 1 } qw( kernel_module min_branch max_branch name );
144  
145 # A hashref or requirement object -> requirement object. Callable on the class
146 # (BUILDARGS) and on an object (adopt).
147 15 ▶sub _coerce_requirement {
Subroutine _coerce_requirement: called CC=7 SCAR=19.7
148 15 my ( $self, $req ) = @_;
149 15 my $base = $self->requirement_class;
150 15 ▶ return $req if blessed($req) && $req->isa($base);
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($req) and $req->isa($base) 1 14 15
Condition66%2/3
builtin::blessed($req) and $req->isa($base)
!ll&&!rl&&r
1401
MC/DC50%1/2
builtin::blessed($req) and $req->isa($base)
builtin::blessed($req) $req->isa($base)
Truth table66%2/3
A and B
A= builtin::blessed($req)B= $req->isa($base)
ABresult
0X0
100
111
151 14 ▶ croak __PACKAGE__.': a requirement is a hashref or a '.$base.' object, not '
Branch: 2 branches
BranchTrueFalseTotal
unless ref $req eq "HASH" 1 13 14
defined $req ? : 1 0 1
152 .( defined $req ? "'".$req."'" : 'undef' )
153 unless ref $req eq 'HASH';
154 13 my @unknown = sort grep { !$REQUIREMENT_KEY{$_} } keys %$req;
155 13 ▶ croak __PACKAGE__.': unknown requirement key'.( @unknown == 1 ? '' : 's' ).' '
Branch: 2 branches
BranchTrueFalseTotal
if @unknown 2 11 13
@unknown == 1 ? : 2 0 2
156 .join(', ', @unknown).' -- known: kernel_module, min_branch, max_branch, name'
157 if @unknown;
158 11 return $self->requirement_class->new(name => 'the requirement option', %$req);
159 }
160  
161  
162 12 ▶sub adopt {
Subroutine adopt: called CC=17 SCAR=28.4
Pod documented
163 12 my ( $self, %arg ) = @_;
164 12 ▶ my $gpus = $arg{gpus} // [];
Condition100%2/2
$arg{"gpus"} // []
l!l
111
MC/DC100%1/1
$arg{"gpus"} // []
$arg{"gpus"}
Truth table100%2/2
A
A= $arg{"gpus"}
Aresult
11
00
165 12 ▶ croak __PACKAGE__.'->adopt: gpus must be an arrayref of GPU hashrefs'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $gpus eq "ARRAY" 0 12 12
166 unless ref $gpus eq 'ARRAY';
167 12 ▶ croak ref($self).' object passed as setup => has already run install -- it '
Branch: 1 branch
BranchTrueFalseTotal
if $self->_installed 1 11 12
168 .'holds that host\'s facts and GPUs. Build a new object per host, or pass a '
169 .'class name. No driver package was installed and no package source was added'
170 if $self->_installed;
171 my $extra = defined $arg{extra_requirement}
172 11 ▶ ? $self->_coerce_requirement($arg{extra_requirement}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $arg{'extra_requirement'} ? : 2 9 11
173 11 $self->_check_gpus($gpus);
174 10 ▶ my $nvswitches = $arg{nvswitches} // [];
Condition100%2/2
$arg{"nvswitches"} // []
l!l
19
MC/DC100%1/1
$arg{"nvswitches"} // []
$arg{"nvswitches"}
Truth table100%2/2
A
A= $arg{"nvswitches"}
Aresult
11
00
175 10 ▶ croak __PACKAGE__.'->adopt: nvswitches must be an arrayref'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $nvswitches eq "ARRAY" 0 10 10
176 unless ref $nvswitches eq 'ARRAY';
177 # NVSwitches add the Fabric Manager step and a source filter plan applies;
178 # they do not touch the requirement, so no fixed-requirement check for them.
179 10 ▶ $self->_set_nvswitches($nvswitches) if @$nvswitches && !@{ $self->nvswitches };
Branch: 1 branch
BranchTrueFalseTotal
if @$nvswitches and not @{$self->nvswitches;} 1 9 10
Condition66%2/3
@$nvswitches and not @{$self->nvswitches;}
!ll&&!rl&&r
901
MC/DC50%1/2
@$nvswitches and not @{$self->nvswitches;}
@$nvswitches not @{$self->nvswitches;}
Truth table66%2/3
A and not(B)
A= @$nvswitchesB= not @{$self->nvswitches;}
ABresult
0X0
100
111
180 10 ▶ my $take_gpus = @$gpus && !@{ $self->gpus };
Condition100%3/3
@$gpus && !@{$self->gpus;}
!ll&&!rl&&r
415
MC/DC100%2/2
@$gpus && !@{$self->gpus;}
@$gpus !@{$self->gpus;}
Truth table100%3/3
A && not(B)
A= @$gpusB= !@{$self->gpus;}
ABresult
0X0
100
111
181 10 ▶ return $self unless $take_gpus || $extra;
Branch: 1 branch
BranchTrueFalseTotal
unless $take_gpus or $extra 3 7 10
Condition100%3/3
$take_gpus or $extra
l!l&&r!l&&!r
523
MC/DC100%2/2
$take_gpus or $extra
$take_gpus $extra
Truth table100%3/3
A or B
A= $take_gpusB= $extra
ABresult
1X1
011
000
182 7 ▶ croak ref($self).' object passed as setup => already has a fixed requirement '
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_requirement 1 6 7
183 .'(given to new or built by plan), so the detected GPUs or the requirement '
184 .'option could not be checked. Build it without requirement =>, or pass a '
185 .'class name. No driver package was installed and no package source was added'
186 if $self->_has_requirement;
187 6 ▶ croak ref($self).' object passed as setup => has an extra_requirement of its '
Branch: 1 branch
BranchTrueFalseTotal
if $extra and $self->extra_requirement 1 5 6
Condition100%3/3
$extra and $self->extra_requirement
!ll&&!rl&&r
411
MC/DC100%2/2
$extra and $self->extra_requirement
$extra $self->extra_requirement
Truth table100%3/3
A and B
A= $extraB= $self->extra_requirement
ABresult
0X0
100
111
188 .'own and the requirement option was given too; pass one of them. No driver '
189 .'package was installed and no package source was added'
190 if $extra && $self->extra_requirement;
191 5 ▶ $self->_set_gpus($gpus) if $take_gpus;
Branch: 1 branch
BranchTrueFalseTotal
if $take_gpus 4 1 5
192 5 ▶ $self->_set_extra_requirement($extra) if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 1 4 5
193 5 return $self;
194 }
195  
196  
197 36 has os => ( is => 'lazy' );
198 36 has release => ( is => 'lazy' );
199 36 has arch => ( is => 'lazy' );
200 36 has kernel => ( is => 'lazy' );
201  
202 439 ▶sub _build_os { Rex::Commands::Gather::operating_system() }
Subroutine _build_os: called CC=1 SCAR=0.0
203 356 ▶sub _build_release { Rex::Commands::Gather::operating_system_release() }
Subroutine _build_release: called CC=1 SCAR=0.0
204  
205 155 ▶sub _build_arch {
Subroutine _build_arch: called CC=2 SCAR=7.0
206 155 my ( $self ) = @_;
207 155 my $arch = $self->run_cmd('uname -m', auto_die => 0);
208 155 ▶ chomp $arch if defined $arch;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arch 155 0 155
209 155 return $arch;
210 }
211  
212 440 ▶sub _build_kernel {
Subroutine _build_kernel: called CC=1 SCAR=0.0
213 440 my ( $self ) = @_;
214 # auto_die left to Rex's default, as install_driver always read it
215 440 my $kernel = $self->run_cmd('uname -r');
216 440 chomp $kernel;
217 440 return $kernel;
218 }
219  
220 #### The host seam ############################################################
221  
222  
223 5214 ▶sub run_cmd { my ( $self, @args ) = @_; return Rex::Commands::Run::run(@args) }
Subroutine run_cmd: called CC=1 SCAR=0.0
Pod documented
224 103 ▶sub pkg_cmd { my ( $self, @args ) = @_; return Rex::Commands::Pkg::pkg(@args) }
Subroutine pkg_cmd: called CC=1 SCAR=0.0
Pod documented
225 438 ▶sub file_cmd { my ( $self, @args ) = @_; return Rex::Commands::File::file(@args) }
Subroutine file_cmd: called CC=1 SCAR=0.0
Pod documented
226  
227 #### The flow #################################################################
228  
229  
230 # Set once install starts: the object has read (and cached) one host's facts
231 # and GPUs, so adopt refuses to hand it to another host.
232 36 has _installed => ( is => 'rwp', init_arg => undef );
233  
234 561 ▶sub install {
Subroutine install: called CC=4 SCAR=13.9
Pod documented
235 561 my ( $self ) = @_;
236 561 $self->_set__installed(1);
237 561 ▶ return 0 if $self->already_installed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->already_installed 62 499 561
238 499 my $plan = $self->plan;
239 394 $self->prepare_host($plan);
240 392 $self->prepare_source($plan);
241 380 $self->resolve_plan($plan);
242 372 $self->install_packages($plan);
243 372 $self->verify_packages($plan);
244 367 ▶ $self->install_fabric_manager($plan) if $self->fabric_manager_needed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->fabric_manager_needed 22 345 367
245 362 ▶ $self->install_nvlink_fabric($plan) if $self->nvlink_fabric_needed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->nvlink_fabric_needed 12 350 362
246 360 $self->post_install($plan);
247 360 return 1;
248 }
249  
250  
251 563 ▶sub already_installed {
Subroutine already_installed: called CC=4 SCAR=13.9
Pod documented
252 563 my ( $self ) = @_;
253 # nvidia-smi -L lists a "GPU N:" device only when the module is loaded and
254 # functional, so it is the safe, OS-neutral signal. Distro-neutral and
255 # BEFORE package selection: a host set up from NVIDIA's CUDA repo would
256 # otherwise get a different (possibly lower) driver whose libs conflict.
257 563 my $smi = $self->run_cmd('nvidia-smi -L 2>&1', auto_die => 0);
258 563 ▶ chomp $smi if defined $smi;
Branch: 1 branch
BranchTrueFalseTotal
if defined $smi 563 0 563
259 563 ▶ return 0 unless $self->_driver_present($smi);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_driver_present($smi) 478 85 563
260 # ... and libcuda (karr #42): a module without the CUDA user-space library
261 # cannot run a CUDA workload, so it is not "installed". Probed only after
262 # nvidia-smi passed: a fresh host runs no more than the one probe.
263 85 ▶ unless ($self->_libcuda_present) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_libcuda_present) 23 62 85
264 23 Rex::Logger::info("nvidia-smi lists a GPU ($smi) but libcuda.so.1 is not in the "
265 .'linker cache (ldconfig -p) — installing the driver packages', 'warn');
266 23 return 0;
267 }
268 62 Rex::Logger::info("NVIDIA driver already present and working — skipping driver install ($smi)");
269 62 return 1;
270 }
271  
272 439 ▶sub libcuda_command { q{/sbin/ldconfig -p 2>/dev/null | grep -q '^[[:space:]]*libcuda\.so\.1 '} }
Subroutine libcuda_command: called CC=1 SCAR=0.0
Pod documented
273  
274 # Runs libcuda_command; 1 if it exited 0.
275 85 ▶sub _libcuda_present {
Subroutine _libcuda_present: called CC=2 SCAR=6.9
276 85 my ( $self ) = @_;
277 85 $self->run_cmd($self->libcuda_command, auto_die => 0);
278 85 ▶ return $? == 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$? == 0 ? : 62 23 85
279 }
280  
281  
282 596 ▶sub plan {
Subroutine plan: called CC=10 SCAR=23.0
Pod documented
283 596 my ( $self ) = @_;
284 # vGPU guest (karr #24): after already_installed (a guest whose vGPU
285 # driver runs passes there) and before anything on the host is changed.
286 596 $self->_reject_vgpu_guest;
287 # Kepler or older (karr #26), on any GPU in the list: die here, after
288 # already_installed (a host whose operator installed 470 by hand still
289 # passes) and before anything on the host is changed or even read.
290 570 $self->_reject_unsupported_gpu($_) for @{ $self->gpus };
291 # Multi-GPU (karr #33): one driver for all of them, or die untouched.
292 522 my $requirement = $self->requirement;
293 498 Rex::Logger::info('Installing NVIDIA drivers on '.$self->os.' (kernel '.$self->kernel.')');
294 Rex::Logger::info(' Driver requirement: '.$requirement->who.': '.$requirement->describe)
295 498 ▶ if @{ $self->gpus } || $self->extra_requirement;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->gpus;} or $self->extra_requirement 465 33 498
Condition66%2/3
@{$self->gpus;} or $self->extra_requirement
l!l&&r!l&&!r
465033
MC/DC50%1/2
@{$self->gpus;} or $self->extra_requirement
@{$self->gpus;} $self->extra_requirement
Truth table66%2/3
A or B
A= @{$self->gpus;}B= $self->extra_requirement
ABresult
1X1
011
000
296  
297 498 my $plan = { packages => [ $self->kernel_packages ], verify => [] };
298 498 my @sources = $self->sources;
299 498 ▶ return $plan unless @sources;
Branch: 1 branch
BranchTrueFalseTotal
unless @sources 1 497 498
300 497 my $source = $self->select_source(@sources);
301 # HGX B200/B300 (karr #56): nvlsm must have a source too, known before any
302 # change -- a driver without it cannot run CUDA there either.
303 477 ▶ if ($self->nvlink_fabric_needed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->nvlink_fabric_needed) 25 452 477
304 25 my $why = $self->nvlink_fabric_unavailable($source);
305 25 ▶ die 'HGX B200/B300 on this '.$self->os.' '.( $self->release // '' ).' host: '.$why
Branch: 1 branch
BranchTrueFalseTotal
if defined $why 3 22 25
Condition50%1/2
$self->release // ""
l!l
30
MC/DC0%0/1
$self->release // ""
$self->release
Truth table50%1/2
A
A= $self->release
Aresult
11
00
306 .'. Without nvlsm and Fabric Manager CUDA fails with cudaErrorSystemNotReady, so '
307 .'no driver package was installed and no package source was added. Install the '
308 ."driver, Fabric Manager and nvlsm yourself\n" if defined $why;
309 }
310 474 $plan->{source} = $source;
311 474 ▶ push @{ $plan->{packages} }, @{ $source->{packages} // [] };
Condition100%2/2
$source->{"packages"} // []
l!l
37698
MC/DC100%1/1
$source->{"packages"} // []
$source->{"packages"}
Truth table100%2/2
A
A= $source->{"packages"}
Aresult
11
00
312 474 ▶ $plan->{verify} = [ @{ $source->{verify} // [] } ];
Condition100%2/2
$source->{"verify"} // []
l!l
37698
MC/DC100%1/1
$source->{"verify"} // []
$source->{"verify"}
Truth table100%2/2
A
A= $source->{"verify"}
Aresult
11
00
313 474 return $plan;
314 }
315  
316 81 ▶sub kernel_packages { () }
Subroutine kernel_packages: called CC=1 SCAR=0.0
Pod documented
317 1 ▶sub sources { () }
Subroutine sources: called CC=1 SCAR=0.0
Pod documented
318  
319 284 ▶sub resolve_source {
Subroutine resolve_source: called CC=1 SCAR=0.0
Pod documented
320 284 my ( $self, $source ) = @_;
321 284 return $source;
322 }
323  
324 497 ▶sub select_source {
Subroutine select_source: called CC=6 SCAR=17.9
Pod documented
325 497 my ( $self, @candidates ) = @_;
326 497 my $requirement = $self->requirement;
327 497 my @rejected;
328 497 for my $candidate (@candidates) {
329 720 ▶ my $why = $candidate->{unavailable} // $requirement->why_not($candidate)
Condition100%6/6
($candidate->{"unavailable"} // $requirement->why_not($candidate)) // $self->_fabric_manager_why_not($candidate)
l!l&&r!l&&!r
2367477
$candidate->{"unavailable"} // $requirement->why_not($candidate)
l!l&&r!l&&!r
15221484
MC/DC100%3/3
($candidate->{"unavailable"} // $requirement->why_not($candidate)) // $self->_fabric_manager_why_not($candidate)
$candidate->{"unavailable"} $requirement->why_not($candidate) $self->_fabric_manager_why_not($candidate)
Truth table100%4/4
A // B // C
A= $candidate->{"unavailable"}B= $requirement->why_not($candidate)C= $self->_fabric_manager_why_not($candidate)
ABCresult
1XX1
01X1
0011
0000
330 // $self->_fabric_manager_why_not($candidate);
331 720 ▶ unless (defined $why) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $why) 477 243 720
332 477 Rex::Logger::info(' Driver source: '.$candidate->{name});
333 477 return $candidate;
334 }
335 243 push @rejected, $candidate->{name}.': '.$why;
336 }
337 20 ▶ die 'No NVIDIA driver source on this '.$self->os.' '.( $self->release // '' ).' host fits '
Condition100%2/2
$self->release // ""
l!l
191
MC/DC100%1/1
$self->release // ""
$self->release
Truth table100%2/2
A
A= $self->release
Aresult
11
00
338 .$requirement->who.' ('.$requirement->describe.') -- '.join('; ', @rejected)
339 .'. No driver package was installed and no package source was added. Install '
340 .'the driver yourself; once '
341 ."`nvidia-smi -L` lists the GPU and libcuda.so.1 is in the linker cache, "
342 ."install_driver skips the driver step\n";
343 }
344  
345 386 ▶sub resolve_plan {
Subroutine resolve_plan: called CC=11 SCAR=24.5
Pod documented
346 386 my ( $self, $plan ) = @_;
347 386 ▶ my $source = $plan->{source} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $source = $plan->{"source"} or return 386 0 386
348 # After prepare_source (karr #35): the package index is fresh now, so a
349 # source that picks its package from it (Ubuntu's apt-cache search) sees
350 # what the repository carries, not a fresh image's stale or empty lists.
351 386 my $resolved = $self->resolve_source($source);
352 386 my $requirement = $self->requirement;
353 386 ▶ my $why = $resolved->{unavailable} // $requirement->why_not($resolved);
Condition100%3/3
$resolved->{"unavailable"} // $requirement->why_not($resolved)
l!l&&r!l&&!r
73376
MC/DC100%2/2
$resolved->{"unavailable"} // $requirement->why_not($resolved)
$resolved->{"unavailable"} $requirement->why_not($resolved)
Truth table100%3/3
A // B
A= $resolved->{"unavailable"}B= $requirement->why_not($resolved)
ABresult
1X1
011
000
354 386 ▶ die 'The NVIDIA driver source '.$source->{name}.' chosen for '.$requirement->who
Branch: 1 branch
BranchTrueFalseTotal
if defined $why 10 376 386
Condition50%1/2
$self->release // ""
l!l
100
MC/DC0%0/1
$self->release // ""
$self->release
Truth table50%1/2
A
A= $self->release
Aresult
11
00
355 .' ('.$requirement->describe.') has nothing to install on this '.$self->os.' '
356 .( $self->release // '' ).' host: '.$why.'. No driver package was installed, '
357 .'only the package sources were prepared. Install the driver yourself; once '
358 ."`nvidia-smi -L` lists the GPU and libcuda.so.1 is in the linker cache, "
359 ."install_driver skips the driver step\n"
360 if defined $why;
361 376 ▶ $self->_check_fabric_manager_source($resolved) if $self->fabric_manager_needed;
Branch: 1 branch
BranchTrueFalseTotal
if $self->fabric_manager_needed 24 352 376
362 375 ▶ return if $resolved == $source;
Branch: 1 branch
BranchTrueFalseTotal
if $resolved == $source 307 68 375
363 0 ▶ my %old = map { $_ => 1 } @{ $source->{packages} // [] };
Condition50%1/2
$source->{"packages"} // []
l!l
068
MC/DC0%0/1
$source->{"packages"} // []
$source->{"packages"}
Truth table50%1/2
A
A= $source->{"packages"}
Aresult
11
00
364 68 $plan->{source} = $resolved;
365 68 $plan->{packages} = [ ( grep { !$old{$_} } @{ $plan->{packages} } ),
366 68 ▶ @{ $resolved->{packages} // [] } ];
Condition50%1/2
$resolved->{"packages"} // []
l!l
680
MC/DC0%0/1
$resolved->{"packages"} // []
$resolved->{"packages"}
Truth table50%1/2
A
A= $resolved->{"packages"}
Aresult
11
00
367 68 ▶ $plan->{verify} = [ @{ $resolved->{verify} // [] } ];
Condition50%1/2
$resolved->{"verify"} // []
l!l
680
MC/DC0%0/1
$resolved->{"verify"} // []
$resolved->{"verify"}
Truth table50%1/2
A
A= $resolved->{"verify"}
Aresult
11
00
368 68 ▶ Rex::Logger::info(' Driver packages: '.join(', ', @{ $resolved->{packages} // [] }));
Condition50%1/2
$resolved->{"packages"} // []
l!l
680
MC/DC0%0/1
$resolved->{"packages"} // []
$resolved->{"packages"}
Truth table50%1/2
A
A= $resolved->{"packages"}
Aresult
11
00
369 68 return;
370 }
371  
372 # NVSwitch host (karr #23): a source that names no Fabric Manager package
373 # cannot make the GPUs usable -- without Fabric Manager CUDA init fails with
374 # cudaErrorSystemNotReady -- so it does not fit, like a wrong branch.
375 484 ▶sub _fabric_manager_why_not {
Subroutine _fabric_manager_why_not: called CC=3 SCAR=11.0
376 484 my ( $self, $source ) = @_;
377 484 ▶ return unless $self->fabric_manager_needed;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->fabric_manager_needed 441 43 484
378 43 ▶ return if defined $source->{fabric_manager};
Branch: 1 branch
BranchTrueFalseTotal
if defined $source->{"fabric_manager"} 36 7 43
379 7 return 'no NVIDIA Fabric Manager package for the '.$self->fabric_label.' on this host';
380 }
381  
382 # After resolve (the branch is exact now): the package name must be complete
383 # and the repository must carry it -- dies before any driver package goes in.
384 24 ▶sub _check_fabric_manager_source {
Subroutine _check_fabric_manager_source: called CC=4 SCAR=14.5
385 24 my ( $self, $source ) = @_;
386 24 my $fm = $self->fabric_manager_package($source);
387 my $why = defined $fm
388 ? $self->fabric_manager_unavailable($fm)
389 24 ▶ : 'its Fabric Manager package '.( $source->{fabric_manager} // '(none)' )
Branch: 1 branch
BranchTrueFalseTotal
defined $fm ? : 24 0 24
Condition0%0/2
$source->{"fabric_manager"} // "(none)"
l!l
00
MC/DC0%0/1
$source->{"fabric_manager"} // "(none)"
$source->{"fabric_manager"}
Truth table0%0/2
A
A= $source->{"fabric_manager"}
Aresult
11
00
390 .' needs an exact driver branch, and none is known';
391 24 ▶ die 'The NVIDIA driver source '.$source->{name}.' has no Fabric Manager for the '
Branch: 1 branch
BranchTrueFalseTotal
if defined $why 1 23 24
392 .$self->fabric_label.' on this host: '.$why.'. No driver package was installed, only the package sources '
393 ."were prepared. Install the driver and a Fabric Manager of exactly its version yourself\n"
394 if defined $why;
395 23 Rex::Logger::info(' Fabric Manager package: '.$fm);
396 23 return;
397 }
398  
399  
400 84 ▶sub fabric_manager_package {
Subroutine fabric_manager_package: called CC=1 SCAR=0.0
Pod documented
401 84 my ( $self, $source ) = @_;
402 84 return $self->_with_branch($source->{fabric_manager}, $source);
403 }
404  
405 9 ▶sub fabric_manager_unavailable { return }
Subroutine fabric_manager_unavailable: called CC=1 SCAR=0.0
Pod documented
406  
407 103 ▶sub fabric_manager_service { 'nvidia-fabricmanager.service' }
Subroutine fabric_manager_service: called CC=1 SCAR=0.0
Pod documented
408  
409 24 ▶sub install_fabric_manager {
Subroutine install_fabric_manager: called CC=6 SCAR=18.0
Pod documented
410 24 my ( $self, $plan ) = @_;
411 24 ▶ my $source = $plan->{source} // {};
Condition50%1/2
$plan->{"source"} // {}
l!l
240
MC/DC0%0/1
$plan->{"source"} // {}
$plan->{"source"}
Truth table50%1/2
A
A= $plan->{"source"}
Aresult
11
00
412 24 my $fm = $self->fabric_manager_package($source);
413 24 ▶ die 'No Fabric Manager package is known for the '.$self->fabric_label.' on this host; the '
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fm 0 24 24
414 ."driver is installed, Fabric Manager is not\n" unless defined $fm;
415 24 my $version = $self->installed_driver_version($source);
416 22 ▶ die 'Cannot read the installed NVIDIA driver version ('.( $version // 'nothing' ).'); '
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_driver_version($version) 1 21 22
Condition50%1/2
$version // "nothing"
l!l
01
MC/DC0%0/1
$version // "nothing"
$version
Truth table50%1/2
A
A= $version
Aresult
11
00
417 .'Fabric Manager must match it exactly, so none was installed. The driver is '
418 ."installed, Fabric Manager is not\n"
419 unless $self->_is_driver_version($version);
420 21 Rex::Logger::info(' Installing NVIDIA Fabric Manager '.$fm.' '.$version.' ('.$self->fabric_label.')');
421 21 $self->install_versioned_package($fm, $version);
422 20 $self->verify_versioned_package($fm, $version);
423 18 my $unit = $self->fabric_manager_service;
424 18 $self->run_cmd('systemctl enable '.$unit, auto_die => 0);
425 18 ▶ die 'systemctl enable '.$unit.' failed after installing '.$fm.' '.$version."\n"
Branch: 1 branch
BranchTrueFalseTotal
if $? != 0 1 17 18
426 if $? != 0;
427 17 return;
428 }
429  
430  
431 24 ▶sub retrofit_fabric_manager {
Subroutine retrofit_fabric_manager: called CC=16 SCAR=27.7
Pod documented
432 24 my ( $self ) = @_;
433 24 ▶ return 0 unless $self->fabric_manager_needed;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->fabric_manager_needed 0 24 24
434 24 my $unit = $self->fabric_manager_service;
435 24 my $version = $self->loaded_driver_version;
436 24 my @present = $self->installed_fabric_managers;
437 24 ▶ if (@present) {
Branch: 1 branch
BranchTrueFalseTotal
if (@present) 7 17 24
438 7 ▶ my @other = grep { !defined $version || !defined $_->[1] || $_->[1] ne $version } @present;
Condition83%5/6
!(defined $version && defined $_->[1]) || $_->[1] ne $version
l!l&&r!l&&!r
115
defined $version && defined $_->[1]
!ll&&!rl&&r
016
MC/DC66%2/3
!(defined $version && defined $_->[1]) || $_->[1] ne $version
defined $version defined $_->[1] $_->[1] ne $version
Truth table75%3/4
not(A && B) || C
A= defined $versionB= defined $_->[1]C= $_->[1] ne $version
ABCresult
0XX1
10X1
1111
1100
439 7 ▶ Rex::Logger::info($self->fabric_label.': Fabric Manager '.join(', ', map { $_->[0].' '.( $_->[1] // 'unknown' ) } @other)
Branch: 1 branch
BranchTrueFalseTotal
if @other 2 5 7
Condition75%3/4
$_->[1] // "unknown"
l!l
11
$version // "unknown"
l!l
20
MC/DC100%1/1
$_->[1] // "unknown"
$_->[1]
MC/DC0%0/1
$version // "unknown"
$version
Truth table100%2/2
A
A= $_->[1]
Aresult
11
00
Truth table50%1/2
A
A= $version
Aresult
11
00
440 .' is installed, but the loaded NVIDIA driver is '.( $version // 'unknown' )
441 .'. Fabric Manager must match the driver exactly or '.$unit.' refuses to start; '
442 .'it is left as it is -- install the matching version yourself', 'warn')
443 if @other;
444 7 return 0;
445 }
446 17 my $fix = 'install NVIDIA Fabric Manager of exactly the loaded driver version yourself';
447 17 ▶ unless ($self->_is_driver_version($version)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_driver_version($version)) 3 14 17
448 3 Rex::Logger::info($self->fabric_label.' present and no Fabric Manager installed, but the loaded '
449 .'driver version cannot be read (nvidia-smi --query-gpu=driver_version); nothing '
450 .'was installed -- '.$fix, 'warn');
451 3 return 0;
452 }
453 14 my ($branch) = $version =~ /^(\d+)\./;
454 14 my ( %seen, @packages );
455 14 for my $source ($self->sources) {
456 35 my $fm = $self->fabric_manager_package({ %$source, branch => $branch });
457 35 ▶ push @packages, $fm if defined $fm && !$seen{$fm}++;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fm and not $seen{$fm}++ 13 22 35
Condition100%3/3
defined $fm and not $seen{$fm}++
!ll&&!rl&&r
41813
MC/DC100%2/2
defined $fm and not $seen{$fm}++
defined $fm not $seen{$fm}++
Truth table100%3/3
A and not(B)
A= defined $fmB= not $seen{$fm}++
ABresult
0X0
100
111
458 }
459 14 ▶ unless (@packages) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@packages) 1 13 14
460 1 Rex::Logger::info($self->fabric_label.' present and no Fabric Manager installed: no driver source '
461 .'Rex::GPU knows on this '.$self->os.' host has a Fabric Manager package, so none is '
462 .'installed for the loaded driver '.$version.' -- '.$fix, 'warn');
463 1 return 0;
464 }
465 13 $self->refresh_package_index;
466 13 my @why;
467 13 for my $fm (@packages) {
468 13 my $why = $self->fabric_manager_version_unavailable($fm, $version);
469 13 ▶ if (defined $why) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $why) 6 7 13
470 6 push @why, $why;
471 6 next;
472 }
473 7 Rex::Logger::info(' Installing NVIDIA Fabric Manager '.$fm.' '.$version
474 .' for the already-installed driver ('.$self->fabric_label.')');
475 7 $self->install_versioned_package($fm, $version);
476 7 $self->verify_versioned_package($fm, $version);
477 6 $self->run_cmd('systemctl enable '.$unit, auto_die => 0);
478 6 ▶ die 'systemctl enable '.$unit.' failed after installing '.$fm.' '.$version
Branch: 1 branch
BranchTrueFalseTotal
if $? != 0 1 5 6
479 ."; the driver is unchanged\n" if $? != 0;
480 5 return 1;
481 }
482 6 Rex::Logger::info($self->fabric_label.' present and no Fabric Manager installed: the package sources '
483 .'configured on this host offer none for the loaded driver '.$version.' ('
484 .join('; ', @why).'). No package source was added and nothing was installed -- '
485 .$fix, 'warn');
486 6 return 0;
487 }
488  
489 0 ▶sub installed_fabric_managers { () }
Subroutine installed_fabric_managers: not called CC=1 SCAR=6.9
Pod documented
490  
491 24 ▶sub loaded_driver_version {
Subroutine loaded_driver_version: called CC=6 SCAR=18.0
Pod documented
492 24 my ( $self ) = @_;
493 24 my $out = $self->run_cmd('nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>&1',
494 auto_die => 0);
495 24 ▶ return if $? != 0 || !defined $out;
Branch: 1 branch
BranchTrueFalseTotal
if $? != 0 or not defined $out 1 23 24
Condition66%2/3
$? != 0 or not defined $out
l!l&&r!l&&!r
1023
MC/DC50%1/2
$? != 0 or not defined $out
$? != 0 not defined $out
Truth table66%2/3
A or not(B)
A= $? != 0B= not defined $out
ABresult
1X1
011
000
496 23 my %v;
497 23 $v{ s/^\s+|\s+$//gr } = 1 for grep { /\S/ } split /\n/, $out;
498 23 ▶ return unless keys %v == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %v == 1 2 21 23
499 21 my ($version) = keys %v;
500 21 ▶ return $self->_is_driver_version($version) ? $version : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_driver_version($version) ? : 21 0 21
501 }
502  
503 4 ▶sub refresh_package_index { }
Subroutine refresh_package_index: called CC=1 SCAR=0.0
Pod documented
504  
505 0 ▶sub fabric_manager_version_unavailable {
Subroutine fabric_manager_version_unavailable: not called CC=1 SCAR=6.9
Pod documented
506 0 my ( $self, $pkg ) = @_;
507 0 return ref($self).' cannot list the versions of '.$pkg.' its package sources offer';
508 }
509  
510 # Pure: is this package name a Fabric Manager (nvidia-fabricmanager,
511 # nvidia-fabricmanager-580, the older nvidia-fabric-manager)? Not -dev or
512 # libnvidia-nscq.
513 15 ▶sub _is_fabric_manager_name {
Subroutine _is_fabric_manager_name: called CC=3 SCAR=11.1
514 15 my ( $self, $name ) = @_;
515 15 ▶ return defined $name && $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $name && $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/ ? : 11 4 15
Condition66%2/3
defined $name and $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/
!ll&&!rl&&r
0411
MC/DC50%1/2
defined $name and $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/
defined $name $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/
Truth table66%2/3
A and B
A= defined $nameB= $name =~ /\Anvidia-fabric-?manager(?:-\d+)?\z/
ABresult
0X0
100
111
516 }
517  
518 0 ▶sub installed_driver_version {
Subroutine installed_driver_version: not called CC=1 SCAR=6.9
Pod documented
519 0 my ( $self ) = @_;
520 0 die ref($self)." has no packaging layer to read the driver version from\n";
521 }
522  
523 0 ▶sub install_versioned_package {
Subroutine install_versioned_package: not called CC=1 SCAR=6.9
Pod documented
524 0 my ( $self ) = @_;
525 0 die ref($self)." has no packaging layer to install Fabric Manager with\n";
526 }
527  
528 0 ▶sub verify_versioned_package {
Subroutine verify_versioned_package: not called CC=1 SCAR=6.9
Pod documented
529 0 my ( $self ) = @_;
530 0 die ref($self)." has no packaging layer to verify Fabric Manager with\n";
531 }
532  
533 # Pure: an NVIDIA driver version, "580.95.05" / "570.211.01" -- two or three
534 # dot-separated numbers, nothing else.
535 62 ▶sub _is_driver_version {
Subroutine _is_driver_version: called CC=3 SCAR=11.0
536 62 my ( $self, $version ) = @_;
537 62 ▶ return defined $version && $version =~ /\A\d+\.\d+(?:\.\d+)?\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $version && $version =~ /\A\d+\.\d+(?:\.\d+)?\z/ ? : 57 5 62
Condition100%3/3
defined $version and $version =~ /\A\d+\.\d+(?:\.\d+)?\z/
!ll&&!rl&&r
4157
MC/DC100%2/2
defined $version and $version =~ /\A\d+\.\d+(?:\.\d+)?\z/
defined $version $version =~ /\A\d+\.\d+(?:\.\d+)?\z/
Truth table100%3/3
A and B
A= defined $versionB= $version =~ /\A\d+\.\d+(?:\.\d+)?\z/
ABresult
0X0
100
111
538 }
539  
540 # Pure: a source key's %s filled with the source's exact branch; undef when
541 # there is no key, or a %s and no exact branch.
542 108 ▶sub _with_branch {
Subroutine _with_branch: called CC=4 SCAR=13.9
543 108 my ( $self, $name, $source ) = @_;
544 108 ▶ return unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 6 102 108
545 102 ▶ return $name unless $name =~ /%s/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /%s/ 45 57 102
546 57 ▶ return unless defined $source->{branch};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $source->{"branch"} 1 56 57
547 56 ( my $filled = $name ) =~ s/%s/$source->{branch}/g;
548 56 return $filled;
549 }
550  
551 #### HGX B200/B300 NVLink fabric (karr #56) ###################################
552  
553  
554 0 ▶sub nvlink_fabric_packages { () }
Subroutine nvlink_fabric_packages: not called CC=1 SCAR=6.9
Pod documented
555  
556 0 ▶sub nvlink_fabric_unavailable {
Subroutine nvlink_fabric_unavailable: not called CC=2 SCAR=17.9
Pod documented
557 0 my ( $self ) = @_;
558 0 ▶ return if $self->nvlink_fabric_packages;
Branch: 1 branch
BranchTrueFalseTotal
if $self->nvlink_fabric_packages 0 0 0
559 0 return ref($self).' knows no package source for the NVLink Subnet Manager (nvlsm)';
560 }
561  
562 4 ▶sub prepare_nvlink_fabric_source { }
Subroutine prepare_nvlink_fabric_source: called CC=1 SCAR=0.0
Pod documented
563  
564 12 ▶sub install_nvlink_fabric {
Subroutine install_nvlink_fabric: called CC=1 SCAR=0.0
Pod documented
565 12 my ( $self, $plan ) = @_;
566 12 $self->warn_nvlink_kernel;
567 12 my @packages = $self->nvlink_fabric_packages;
568 12 Rex::Logger::info(' HGX B200/B300: NVLink Subnet Manager and InfiniBand user space ('
569 .join(', ', @packages).')');
570 12 $self->prepare_nvlink_fabric_source($plan);
571 11 $self->install_packages({ packages => [ @packages ] });
572 11 $self->verify_packages({ verify => [ @packages ] });
573 10 $self->load_ib_umad;
574 10 return;
575 }
576  
577 2 ▶sub retrofit_nvlink_fabric {
Subroutine retrofit_nvlink_fabric: called CC=7 SCAR=19.8
Pod documented
578 2 my ( $self ) = @_;
579 2 $self->warn_nvlink_kernel;
580 2 my @packages = $self->nvlink_fabric_packages;
581 2 my @missing = grep { !$self->_package_installed($_) } @packages;
582 2 $self->run_cmd(q{lsmod | grep -q '^ib_umad '}, auto_die => 0);
583 2 my $loaded = $? == 0;
584 2 ▶ return 0 if !@missing && $loaded;
Branch: 1 branch
BranchTrueFalseTotal
if not @missing and $loaded 1 1 2
Condition66%2/3
not @missing and $loaded
!ll&&!rl&&r
101
MC/DC50%1/2
not @missing and $loaded
not @missing $loaded
Truth table66%2/3
not(A) and B
A= not @missingB= $loaded
ABresult
0X0
100
111
585 1 ▶ if (@missing) {
Branch: 1 branch
BranchTrueFalseTotal
if (@missing) 1 0 1
586 1 Rex::Logger::info(' HGX B200/B300: installing '.join(', ', @missing)
587 .' for the already-installed driver, from the host\'s own package sources');
588 1 $self->refresh_package_index;
589 1 $self->install_packages({ packages => [ @missing ] });
590 1 ▶ if (my @still = grep { !$self->_package_installed($_) } @missing) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@still) = grep({not $self->_package_installed($_);} @missing)) 1 0 1
591 1 ▶ Rex::Logger::info('HGX B200/B300: '.join(', ', @still).' not installed -- the package '
Branch: 2 branches
BranchTrueFalseTotal
@still == 1 ? : 1 0 1
@still == 1 ? : 1 0 1
592 .'sources configured on this host do not offer '.( @still == 1 ? 'it' : 'them' )
593 .' (nvlsm comes from NVIDIA\'s CUDA repository). No package source was added; '
594 .'without nvlsm CUDA fails with cudaErrorSystemNotReady -- install '
595 .( @still == 1 ? 'it' : 'them' ).' yourself', 'warn');
596 }
597 }
598 1 $self->load_ib_umad;
599 1 return 1;
600 }
601  
602 # Whether one of nvlink_fabric_packages is installed: verify_packages for it
603 # alone, which dies when it is not.
604 9 ▶sub _package_installed {
Subroutine _package_installed: called CC=2 SCAR=6.9
605 9 my ( $self, $pkg ) = @_;
606 9 ▶ return eval { $self->verify_packages({ verify => [ $pkg ] }); 1 } ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->verify_packages({'verify', [$pkg]}); 1 } } ? : 7 2 9
607 }
608  
609 11 ▶sub load_ib_umad {
Subroutine load_ib_umad: called CC=3 SCAR=12.0
Pod documented
610 11 my ( $self ) = @_;
611 11 $self->file_cmd('/etc/modules-load.d/ib_umad.conf', content => "ib_umad\n");
612 11 $self->run_cmd('modprobe ib_umad', auto_die => 0);
613 11 ▶ Rex::Logger::info('modprobe ib_umad failed: the Fabric Manager start script needs the '
Branch: 1 branch
BranchTrueFalseTotal
if $? != 0 0 11 11
Condition0%0/2
$self->kernel // "\$(uname -r)"
l!l
00
MC/DC0%0/1
$self->kernel // "\$(uname -r)"
$self->kernel
Truth table0%0/2
A
A= $self->kernel
Aresult
11
00
614 .'module, so nvidia-fabricmanager.service will not start until it is loaded (on Ubuntu '
615 .'it is in linux-modules-extra-'.( $self->kernel // '$(uname -r)' ).')', 'warn')
616 if $? != 0;
617 11 return;
618 }
619  
620 16 ▶sub nvlink_kernel_backported { 0 }
Subroutine nvlink_kernel_backported: called CC=1 SCAR=0.0
Pod documented
621  
622 20 ▶sub warn_nvlink_kernel {
Subroutine warn_nvlink_kernel: called CC=8 SCAR=20.8
Pod documented
623 20 my ( $self ) = @_;
624 20 ▶ return if $self->nvlink_kernel_backported;
Branch: 1 branch
BranchTrueFalseTotal
if $self->nvlink_kernel_backported 4 16 20
625 16 my $kernel = $self->kernel;
626 16 ▶ my ( $major, $minor ) = ( $kernel // '' ) =~ /^(\d+)\.(\d+)/;
Condition50%1/2
$kernel // ""
l!l
160
MC/DC0%0/1
$kernel // ""
$kernel
Truth table50%1/2
A
A= $kernel
Aresult
11
00
627 16 ▶ if (!defined $major) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $major) 1 15 16
628 1 ▶ Rex::Logger::info('HGX B200/B300: cannot read the kernel version ('.( $kernel // 'nothing' )
Condition50%1/2
$kernel // "nothing"
l!l
10
MC/DC0%0/1
$kernel // "nothing"
$kernel
Truth table50%1/2
A
A= $kernel
Aresult
11
00
629 .'); NVIDIA requires kernel 5.17 or newer for the NVLink fabric', 'warn');
630 1 return;
631 }
632 15 ▶ return if $major > 5 || ( $major == 5 && $minor >= 17 );
Branch: 1 branch
BranchTrueFalseTotal
if $major > 5 or $major == 5 and $minor >= 17 12 3 15
Condition100%6/6
$major > 5 or $major == 5 and $minor >= 17
l!l&&r!l&&!r
1113
$major == 5 and $minor >= 17
!ll&&!rl&&r
121
MC/DC100%3/3
$major > 5 or $major == 5 and $minor >= 17
$major > 5 $major == 5 $minor >= 17
Truth table100%4/4
A or B and C
A= $major > 5B= $major == 5C= $minor >= 17
ABCresult
1XX1
0111
00X0
0100
633 3 Rex::Logger::info('HGX B200/B300: kernel '.$kernel.' is older than 5.17, which NVIDIA '
634 .'requires for the NVLink 5 fabric (Fabric Manager user guide); Fabric Manager and nvlsm '
635 .'may not come up on it. Boot a newer kernel -- on Ubuntu 22.04 the HWE kernel '
636 .'(linux-generic-hwe-22.04). Rex::GPU does not change the kernel', 'warn');
637 3 return;
638 }
639  
640 11 ▶sub fabric_state_poll { ( 12, 10 ) }
Subroutine fabric_state_poll: called CC=1 SCAR=0.0
Pod documented
641  
642 12 ▶sub check_nvlink_fabric {
Subroutine check_nvlink_fabric: called CC=11 SCAR=24.2
Pod documented
643 12 my ( $self, $active ) = @_;
644 12 my ( $reads, $seconds ) = $self->fabric_state_poll;
645 12 my $want = scalar grep { ref $_ eq 'HASH' } @{ $self->gpus };
646 12 my @states;
647 12 ▶ for my $read (1 .. ( $active ? $reads : 1 )) {
Branch: 1 branch
BranchTrueFalseTotal
$active ? : 10 2 12
648 15 ▶ sleep $seconds if $read > 1 && $seconds;
Branch: 1 branch
BranchTrueFalseTotal
if $read > 1 and $seconds 0 15 15
Condition66%2/3
$read > 1 and $seconds
!ll&&!rl&&r
1230
MC/DC0%0/2
$read > 1 and $seconds
$read > 1 $seconds
Truth table66%2/3
A and B
A= $read > 1B= $seconds
ABresult
0X0
100
111
649 15 my $out = $self->run_cmd('nvidia-smi -q 2>&1', auto_die => 0);
650 15 @states = $self->_fabric_states($out);
651 15 ▶ if ($self->_fabric_complete($want, @states)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_fabric_complete($want, @states)) 9 6 15
652 9 ▶ Rex::Logger::info(' [ok] NVLink fabric: Fabric State Completed, Status Success on '
Branch: 1 branch
BranchTrueFalseTotal
@states == 1 ? : 0 9 9
653 .scalar(@states).' GPU'.( @states == 1 ? '' : 's' ));
654 9 return 1;
655 }
656 }
657 my $seen = @states
658 3 ▶ ? join('; ', map { 'GPU '.$_.': '.( $states[$_]{state} // 'no State' ).' / '
Branch: 1 branch
BranchTrueFalseTotal
@states ? : 2 1 3
659 16 ▶ .( $states[$_]{status} // 'no Status' ) } 0 .. $#states)
Condition50%2/4
$states[$_]{"state"} // "no State"
l!l
160
$states[$_]{"status"} // "no Status"
l!l
160
MC/DC0%0/1
$states[$_]{"state"} // "no State"
$states[$_]{"state"}
MC/DC0%0/1
$states[$_]{"status"} // "no Status"
$states[$_]{"status"}
Truth table50%1/2
A
A= $states[$_]{"state"}
Aresult
11
00
Truth table50%1/2
A
A= $states[$_]{"status"}
Aresult
11
00
660 : 'no Fabric section';
661 3 my $unit = $self->fabric_manager_service;
662 3 ▶ Rex::Logger::info('HGX B200/B300: the NVLink fabric is not up -- nvidia-smi -q reports '
Branch: 1 branch
BranchTrueFalseTotal
$want > @states ? : 1 2 3
663 .$seen.( $want > @states ? ' ('.$want.' GPUs expected)' : '' )
664 .', not State Completed / Status Success on every GPU. CUDA jobs fail with '
665 .'cudaErrorSystemNotReady until it is. Look at systemctl status '.$unit
666 .', journalctl -u '.$unit.', /var/log/nvlsm.log, lsmod | grep ib_umad and the kernel '
667 .'(5.17 or newer); after the first-deploy reboot check again with nvidia-smi -q', 'warn');
668 3 return 0;
669 }
670  
671 # Pure: every "Fabric" section of `nvidia-smi -q` output, in GPU order, as
672 # { state => ..., status => ... } (a key is missing when the section has no
673 # such line). The first State / Status inside the section count; a line
674 # indented no deeper than "Fabric" ends it.
675 22 ▶sub _fabric_states {
Subroutine _fabric_states: called CC=9 SCAR=22.1
676 22 my ( $self, $out ) = @_;
677 22 my ( @states, $cur, $indent );
678 22 ▶ for my $line (split /\n/, $out // '') {
Condition50%1/2
$out // ""
l!l
220
MC/DC0%0/1
$out // ""
$out
Truth table50%1/2
A
A= $out
Aresult
11
00
679 1256 ▶ next unless $line =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /\S/ 0 1256 1256
680 1256 my $depth = length( ( $line =~ /^([ \t]*)/ )[0] );
681 1256 ▶ if ($line =~ /^[ \t]*Fabric[ \t]*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[ \t]*Fabric[ \t]*$/) 140 1116 1256
682 140 $cur = {};
683 140 $indent = $depth;
684 140 push @states, $cur;
685 140 next;
686 }
687 1116 ▶ next unless $cur;
Branch: 1 branch
BranchTrueFalseTotal
unless $cur 280 836 1116
688 836 ▶ if ($depth <= $indent) { undef $cur; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($depth <= $indent) 140 696 836
689 696 ▶ if ($line =~ /^[ \t]*(State|Status)[ \t]*:[ \t]*(.*?)\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[ \t]*(State|Status)[ \t]*:[ \t]*(.*?)\s*$/) 278 418 696
690 278 ▶ $cur->{ lc $1 } //= $2;
Condition33%1/3
$$cur{lc $1} //= $2
l!l&&r!l&&!r
02780
MC/DC0%0/2
$$cur{lc $1} //= $2
$$cur{lc $1} $2
Truth table33%1/3
A //= B
A= $$cur{lc $1}B= $2
ABresult
1X1
011
000
691 }
692 }
693 22 return @states;
694 }
695  
696 # Pure: at least $want sections (and at least one), each Completed / Success.
697 20 ▶sub _fabric_complete {
Subroutine _fabric_complete: called CC=8 SCAR=20.9
698 20 my ( $self, $want, @states ) = @_;
699 20 ▶ return 0 unless @states && @states >= $want;
Branch: 1 branch
BranchTrueFalseTotal
unless @states and @states >= $want 3 17 20
Condition100%3/3
@states and @states >= $want
!ll&&!rl&&r
2117
MC/DC100%2/2
@states and @states >= $want
@states @states >= $want
Truth table100%3/3
A and B
A= @statesB= @states >= $want
ABresult
0X0
100
111
700 17 for my $s (@states) {
701 91 ▶ return 0 unless ( $s->{state} // '' ) eq 'Completed' && ( $s->{status} // '' ) eq 'Success';
Branch: 1 branch
BranchTrueFalseTotal
unless ($s->{"state"} // "") eq "Completed" and ($s->{"status"} // "") eq "Success" 7 84 91
Condition71%5/7
($s->{"state"} // "") eq "Completed" and ($s->{"status"} // "") eq "Success"
!ll&&!rl&&r
6184
$s->{"state"} // ""
l!l
910
$s->{"status"} // ""
l!l
850
MC/DC0%0/2
($s->{"state"} // "") eq "Completed" and ($s->{"status"} // "") eq "Success"
$s->{"state"} $s->{"status"}
Truth table33%1/3
A and B
A= $s->{"state"}B= $s->{"status"}
ABresult
0X0
100
111
702 }
703 10 return 1;
704 }
705  
706  
707 0 ▶sub prepare_host { }
Subroutine prepare_host: not called CC=1 SCAR=0.0
Pod documented
708 0 ▶sub prepare_source { }
Subroutine prepare_source: not called CC=1 SCAR=0.0
Pod documented
709 0 ▶sub install_packages { }
Subroutine install_packages: not called CC=1 SCAR=0.0
Pod documented
710 0 ▶sub verify_packages { }
Subroutine verify_packages: not called CC=1 SCAR=0.0
Pod documented
711  
712  
713 359 ▶sub post_install {
Subroutine post_install: called CC=1 SCAR=0.0
Pod documented
714 359 my ( $self ) = @_;
715 359 $self->file_cmd('/etc/modprobe.d/blacklist-nouveau.conf',
716 content => "blacklist nouveau\noptions nouveau modeset=0\n");
717 359 $self->run_cmd($self->initramfs_command, auto_die => 0);
718 }
719  
720 200 ▶sub initramfs_command { 'dracut --force 2>/dev/null' }
Subroutine initramfs_command: called CC=1 SCAR=0.0
Pod documented
721  
722 #### Pure helpers #############################################################
723 #
724 # Callable on the class as on an object, and with explicit arguments, because
725 # Rex::GPU::NVIDIA keeps some old private names as thin wrappers over them
726 # (t/ calls those).
727  
728 # Given `nvidia-smi -L` output: is a working driver loaded? Every failure form
729 # (NVML init error, "No devices were found", "command not found") does not
730 # match.
731 570 ▶sub _driver_present {
Subroutine _driver_present: called CC=3 SCAR=11.0
732 570 my ( $self, $smi ) = @_;
733 570 ▶ return 0 unless defined $smi;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $smi 1 569 570
734 569 ▶ return $smi =~ /GPU \d+:/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$smi =~ /GPU \d+:/ ? : 87 482 569
735 }
736  
737 # Die for a GPU no installable branch supports -- Kepler or older, max_branch
738 # 470. Maintainer decision (epic karr #25): reject loudly instead of
739 # installing the EOL 470 driver. Quiet for every other GPU, 580 included, and
740 # for anything that is not a GPU hashref.
741 760 ▶sub _reject_unsupported_gpu {
Subroutine _reject_unsupported_gpu: called CC=6 SCAR=17.9
742 760 my ( $self, $gpu ) = @_;
743 760 ▶ return unless $gpu && ref $gpu eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless $gpu and ref $gpu eq "HASH" 3 757 760
Condition100%3/3
$gpu and ref $gpu eq "HASH"
!ll&&!rl&&r
12757
MC/DC100%2/2
$gpu and ref $gpu eq "HASH"
$gpu ref $gpu eq "HASH"
Truth table100%3/3
A and B
A= $gpuB= ref $gpu eq "HASH"
ABresult
0X0
100
111
744 757 my $req = $self->requirement_class->from_gpu($gpu);
745 757 ▶ return unless defined $req->max_branch && $req->max_branch < 580;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $req->max_branch and $req->max_branch < 580 707 50 757
Condition100%3/3
defined $req->max_branch and $req->max_branch < 580
!ll&&!rl&&r
56214550
MC/DC100%2/2
defined $req->max_branch and $req->max_branch < 580
defined $req->max_branch $req->max_branch < 580
Truth table100%3/3
A and B
A= defined $req->max_branchB= $req->max_branch < 580
ABresult
0X0
100
111
746 50 ▶ die "NVIDIA GPU '" . ($gpu->{name} // 'unknown') . "' (10de:$gpu->{device_id}) is "
Condition50%1/2
$gpu->{"name"} // "unknown"
l!l
500
MC/DC0%0/1
$gpu->{"name"} // "unknown"
$gpu->{"name"}
Truth table50%1/2
A
A= $gpu->{"name"}
Aresult
11
00
747 . $req->generation." silicon: no driver newer than the end-of-life "
748 . $req->max_branch." branch supports it, and Rex::GPU does not install "
749 . "that. No driver package was installed and no package source was added. "
750 . "Install the driver yourself; once "
751 . "`nvidia-smi -L` lists the GPU and libcuda.so.1 is in the linker cache, "
752 . "install_driver skips the driver step\n";
753 }
754  
755 # Die for a vGPU guest device among the GPUs (karr #24): it needs NVIDIA's
756 # licensed vGPU guest driver, which no package source carries, and the open
757 # nvidia.ko of the datacenter packages refuses an Ampere+ vGPU function. With
758 # a non-vGPU GPU next to it both are named: one NVIDIA kernel module drives
759 # every GPU of the host, so the two drivers cannot both be installed. A GPU
760 # hash without vgpu (a caller that finds its GPUs itself) is not a vGPU.
761 596 ▶sub _reject_vgpu_guest {
Subroutine _reject_vgpu_guest: called CC=8 SCAR=21.3
762 596 my ( $self ) = @_;
763 596 my @gpus = grep { ref $_ eq 'HASH' } @{ $self->gpus };
764 596 my @vgpu = grep { $_->{vgpu} } @gpus;
765 596 ▶ return unless @vgpu;
Branch: 1 branch
BranchTrueFalseTotal
unless @vgpu 570 26 596
766 26 my @other = grep { !$_->{vgpu} } @gpus;
767 die join('; ', map {
768 'NVIDIA vGPU guest (type '.( $_->{vgpu_type} // 'unknown' ).', 10de:'
769 26 ▶ .( $_->{device_id} // '????' ).' sub '.( $_->{subsystem_id} // '????' ).')'
Branch: 1 branch
BranchTrueFalseTotal
@other ? : 12 14 26
Condition50%3/6
$_->{"vgpu_type"} // "unknown"
l!l
260
$_->{"device_id"} // "????"
l!l
260
$_->{"subsystem_id"} // "????"
l!l
260
MC/DC0%0/1
$_->{"vgpu_type"} // "unknown"
$_->{"vgpu_type"}
MC/DC0%0/1
$_->{"device_id"} // "????"
$_->{"device_id"}
MC/DC0%0/1
$_->{"subsystem_id"} // "????"
$_->{"subsystem_id"}
Truth table50%1/2
A
A= $_->{"vgpu_type"}
Aresult
11
00
Truth table50%1/2
A
A= $_->{"device_id"}
Aresult
11
00
Truth table50%1/2
A
A= $_->{"subsystem_id"}
Aresult
11
00
770 } @vgpu)
771 .( @other
772 ? ' next to '.join(', ', map {
773 26 "NVIDIA GPU '".( $_->{name} // 'unknown' )."' (10de:"
774 12 ▶ .( $_->{device_id} // '????' ).', not a vGPU)'
Condition50%2/4
$_->{"name"} // "unknown"
l!l
120
$_->{"device_id"} // "????"
l!l
120
MC/DC0%0/1
$_->{"name"} // "unknown"
$_->{"name"}
MC/DC0%0/1
$_->{"device_id"} // "????"
$_->{"device_id"}
Truth table50%1/2
A
A= $_->{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $_->{"device_id"}
Aresult
11
00
775 } @other)
776 .': one NVIDIA kernel module drives every GPU of the host, and the '
777 .'driver Rex::GPU installs does not drive a vGPU'
778 : '' )
779 .': install the licensed NVIDIA vGPU guest driver, then run again. '
780 ."No driver package was installed and no package source was added\n";
781 }
782  
783 # `uname -m` / dpkg arch -> the token NVIDIA's CUDA repos use under
784 # repos/<distro>/<arch>/: aarch64/arm64 are "sbsa", everything else (an empty
785 # string included) "x86_64". NOT the libnvidia-container toolkit repo's token,
786 # which is "aarch64" for the same machine.
787 261 ▶sub _cuda_repo_arch {
Subroutine _cuda_repo_arch: called CC=4 SCAR=13.9
788 261 my ( $self, $machine ) = @_;
789 261 ▶ $machine //= '';
Condition100%2/2
$machine //= ""
l!l
2601
MC/DC100%1/1
$machine //= ""
$machine
Truth table100%2/2
A
A= $machine
Aresult
11
00
790 261 ▶ return 'sbsa' if $machine eq 'aarch64' || $machine eq 'arm64';
Branch: 1 branch
BranchTrueFalseTotal
if $machine eq "aarch64" or $machine eq "arm64" 6 255 261
Condition100%3/3
$machine eq "aarch64" or $machine eq "arm64"
l!l&&r!l&&!r
15255
MC/DC100%2/2
$machine eq "aarch64" or $machine eq "arm64"
$machine eq "aarch64" $machine eq "arm64"
Truth table100%3/3
A or B
A= $machine eq "aarch64"B= $machine eq "arm64"
ABresult
1X1
011
000
791 255 return 'x86_64';
792 }
793  
794 # Major version from a raw release string ("10.1" -> 10, "trixie/sid" -> 0).
795 # operating_system_version() strips the dots, so it is never the input.
796 829 ▶sub _major_version {
Subroutine _major_version: called CC=3 SCAR=11.0
797 829 my ( $self, $release ) = @_;
798 829 ▶ my ($major) = ($release // '') =~ /^(\d+)/;
Condition100%2/2
$release // ""
l!l
8281
MC/DC100%1/1
$release // ""
$release
Truth table100%2/2
A
A= $release
Aresult
11
00
799 829 ▶ return ($major // 0) + 0;
Condition100%2/2
$major // 0
l!l
8236
MC/DC100%1/1
$major // 0
$major
Truth table100%2/2
A
A= $major
Aresult
11
00
800 }
801  
802 36 1;
803  
804 __END__
« lib/Rex/GPU/Detect/Sysfs.pm ↑ Summary blib/lib/Rex/GPU/Detect.pm »