lib/Rex/GPU/AMD/Setup/Ubuntu.pm

filter: Statementstmt 100% 48 / 48 Branchbran 75.0% 15 / 20 Conditioncond 76.9% 10 / 13 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 14 / 14 Podpod 100% 11 / 11 totaltotal 90.3% 103 / 114 CC 16 SCAR 9.6
CC
16
Cov
90%
radeon_unsupported
4.2
inbox_only_unsupported
4.0
optional_packages
3.0
CRAP 2.6
« lib/Rex/GPU/NVIDIA/Setup/Rpm.pm ↑ Summary lib/Rex/GPU/NVIDIA/Setup/SUSE.pm »
1 # ABSTRACT: AMD driver setup for Ubuntu 22.04, 24.04 and 26.04 (experimental)
2  
3 package Rex::GPU::AMD::Setup::Ubuntu;
4 40 our $VERSION = '0.006';
5 40 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 extends 'Rex::GPU::AMD::Setup::Apt';
9  
10 # Sources, checked 2026-10-30:
11 # ROCm 10.1 compatibility matrix
12 # https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html
13 # Instinct (amdgpu-dkms): 26.04.1 GA 7.0, 24.04.5 GA 6.8, 22.04.5 GA 5.15;
14 # Radeon (amdgpu-dkms): 26.04.1 GA 7.0, 24.04.5 HWE 7.0, 22.04.5 HWE 6.8;
15 # Ryzen APUs: "Inbox kernel driver in supported Ubuntu version", 26.04.1 GA
16 # 7.0 and 24.04.5 HWE 7.0 only. AMD's Ryzen install page names 24.04.4
17 # with the OEM kernel 6.14 instead (hardware curator, k1). The matrix is
18 # followed, so an APU on 6.14 dies before any change. The Radeon list
19 # binds every GPU of the Radeon table (matrix => 'radeon'), whatever
20 # the method (k82): a Radeon on 24.04 GA 6.8 or 22.04 GA 5.15 dies.
21 # install_rocm binds the Radeon and Ryzen APU targets the same way (k91).
22 # amdgpu 31.60 install guide (instinct.docs.amd.com/projects/amdgpu-docs,
23 # docs-31.60.0): suites resolute/noble/jammy; linux-headers-$K, and on
24 # 24.04/22.04 linux-modules-extra-$K.
25 # synapse (Ubuntu 24.04, 7.0.0-42-generic), 2026-10-31: no package
26 # linux-modules-extra-7.0.0-42-generic (amdgpu.ko is in linux-modules), so
27 # linux-modules-extra-$K is installed only where apt has a candidate.
28 # Firmware: linux-firmware-amd-graphics (noble-updates, resolute), split off
29 # linux-firmware, which depends on it from that version on; an older
30 # linux-firmware still carries the files -- either one installed suffices.
31 40 my %RELEASE = (
32 '26.04' => { suite => 'resolute', dkms => [qw( 7.0 )], inbox_only => [qw( 7.0 )],
33 radeon => [qw( 7.0 )],
34 firmware => [qw( linux-firmware-amd-graphics linux-firmware )],
35 modules_extra => 0, rocm => 'ubuntu2604' },
36 '24.04' => { suite => 'noble', dkms => [qw( 6.8 7.0 )], inbox_only => [qw( 7.0 )],
37 radeon => [qw( 7.0 )],
38 firmware => [qw( linux-firmware-amd-graphics linux-firmware )],
39 modules_extra => 1, rocm => 'ubuntu2404' },
40 '22.04' => { suite => 'jammy', dkms => [qw( 5.15 6.8 )], inbox_only => [],
41 radeon => [qw( 6.8 )],
42 firmware => [qw( linux-firmware )],
43 modules_extra => 1, rocm => 'ubuntu2204' },
44 );
45  
46  
47 344 ▶sub release_data { $RELEASE{ $_[0]->os_version } }
Subroutine release_data: called CC=1 SCAR=0.0
Pod documented
48  
49 137 ▶sub kernel_series {
Subroutine kernel_series: called CC=2 SCAR=6.9
Pod documented
50 137 my ( $self ) = @_;
51 137 ▶ return $self->kernel =~ /\A(\d+\.\d+)\.\d+-\d+-generic\z/ ? $1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->kernel =~ /\A(\d+\.\d+)\.\d+-\d+-generic\z/ ? : 134 3 137
52 }
53  
54 68 ▶sub dkms_suite {
Subroutine dkms_suite: called CC=2 SCAR=7.1
Pod documented
55 68 my ( $self ) = @_;
56 68 ▶ my $row = $self->release_data or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $self->release_data or return 68 0 68
57 68 return $row->{suite};
58 }
59  
60 71 ▶sub dkms_unsupported {
Subroutine dkms_unsupported: called CC=2 SCAR=7.1
Pod documented
61 71 my ( $self ) = @_;
62 71 ▶ my $row = $self->release_data
Branch: 1 branch
BranchTrueFalseTotal
my $row = $self->release_data or return 'amdgpu-dkms ' . $self->amdgpu_release . ' supports Ubuntu 22.04, 24.04 and 26.04, not ' . $self->os_label 71 0 71
63 or return 'amdgpu-dkms '.$self->amdgpu_release.' supports Ubuntu 22.04, 24.04 and 26.04, not '
64 .$self->os_label;
65 71 return $self->_kernel_unsupported('amdgpu-dkms '.$self->amdgpu_release, $row->{dkms});
66 }
67  
68 56 ▶sub inbox_only_unsupported {
Subroutine inbox_only_unsupported: called CC=4 SCAR=13.9
Pod documented
69 56 my ( $self ) = @_;
70 56 my $row = $self->release_data;
71 56 ▶ return $self->SUPER::inbox_only_unsupported unless $row && @{ $row->{inbox_only} };
Branch: 1 branch
BranchTrueFalseTotal
unless $row and @{$row->{"inbox_only"};} 8 48 56
Condition66%2/3
$row and @{$row->{"inbox_only"};}
!ll&&!rl&&r
0848
MC/DC50%1/2
$row and @{$row->{"inbox_only"};}
$row @{$row->{"inbox_only"};}
Truth table66%2/3
A and B
A= $rowB= @{$row->{"inbox_only"};}
ABresult
0X0
100
111
72 48 ▶ my $why = $self->_kernel_unsupported('AMD (inbox driver only)', $row->{inbox_only}) // return;
Condition100%2/2
$self->_kernel_unsupported("AMD (inbox driver only)", $row->{"inbox_only"}) // (return)
l!l
543
MC/DC100%1/1
$self->_kernel_unsupported("AMD (inbox driver only)", $row->{"inbox_only"}) // (return)
$self->_kernel_unsupported("AMD (inbox driver only)", $row->{"inbox_only"})
Truth table100%2/2
A
A= $self->_kernel_unsupported("AMD (inbox driver only)", $row->{"inbox_only"})
Aresult
11
00
73 5 return $why.' -- '.$self->inbox_only_supported;
74 }
75  
76 18 ▶sub radeon_unsupported {
Subroutine radeon_unsupported: called CC=4 SCAR=14.3
Pod documented
77 18 my ( $self ) = @_;
78 18 my $row = $self->release_data;
79 18 ▶ return $self->SUPER::radeon_unsupported unless $row && @{ $row->{radeon} };
Branch: 1 branch
BranchTrueFalseTotal
unless $row and @{$row->{"radeon"};} 0 18 18
Condition33%1/3
$row and @{$row->{"radeon"};}
!ll&&!rl&&r
0018
MC/DC0%0/2
$row and @{$row->{"radeon"};}
$row @{$row->{"radeon"};}
Truth table33%1/3
A and B
A= $rowB= @{$row->{"radeon"};}
ABresult
0X0
100
111
80 18 ▶ my $why = $self->_kernel_unsupported('AMD (Radeon GPUs)', $row->{radeon}) // return;
Condition100%2/2
$self->_kernel_unsupported("AMD (Radeon GPUs)", $row->{"radeon"}) // (return)
l!l
99
MC/DC100%1/1
$self->_kernel_unsupported("AMD (Radeon GPUs)", $row->{"radeon"}) // (return)
$self->_kernel_unsupported("AMD (Radeon GPUs)", $row->{"radeon"})
Truth table100%2/2
A
A= $self->_kernel_unsupported("AMD (Radeon GPUs)", $row->{"radeon"})
Aresult
11
00
81 9 return $why.' -- '.$self->radeon_supported;
82 }
83  
84 137 ▶sub _kernel_unsupported {
Subroutine _kernel_unsupported: called CC=3 SCAR=11.0
85 137 my ( $self, $what, $series ) = @_;
86 137 my $have = $self->kernel_series;
87 137 ▶ return if defined $have && grep { $_ eq $have } @$series;
Branch: 1 branch
BranchTrueFalseTotal
if defined $have and grep {$_ eq $have;} @$series 121 16 137
Condition100%3/3
defined $have and grep {$_ eq $have;} @$series
!ll&&!rl&&r
313121
MC/DC100%2/2
defined $have and grep {$_ eq $have;} @$series
defined $have grep {$_ eq $have;} @$series
Truth table100%3/3
A and B
A= defined $haveB= grep {$_ eq $have;} @$series
ABresult
0X0
100
111
88 16 return $what.' supports '.$self->os_label.' with kernel '.join(' or ', @$series)
89 .' (-generic); this host runs '.$self->kernel;
90 }
91  
92 67 ▶sub kernel_header_packages { 'linux-headers-'.$_[0]->kernel }
Subroutine kernel_header_packages: called CC=1 SCAR=0.0
Pod documented
93  
94 71 ▶sub optional_packages {
Subroutine optional_packages: called CC=3 SCAR=11.1
Pod documented
95 71 my ( $self ) = @_;
96 71 ▶ my $row = $self->release_data or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $self->release_data or return 71 0 71
97 71 ▶ return $row->{modules_extra} ? 'linux-modules-extra-'.$self->kernel : ();
Branch: 1 branch
BranchTrueFalseTotal
$row->{'modules_extra'} ? : 69 2 71
98 }
99  
100 4 ▶sub inbox_module_packages { $_[0]->optional_packages }
Subroutine inbox_module_packages: called CC=1 SCAR=0.0
Pod documented
101  
102 7 ▶sub firmware_packages {
Subroutine firmware_packages: called CC=2 SCAR=7.0
Pod documented
103 7 my ( $self ) = @_;
104 7 ▶ my $row = $self->release_data or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $self->release_data or return 7 0 7
105 7 return @{ $row->{firmware} };
106 }
107  
108 53 ▶sub rocm_repo_dir {
Subroutine rocm_repo_dir: called CC=2 SCAR=6.9
Pod documented
109 53 my ( $self ) = @_;
110 53 ▶ my $row = $self->release_data or return;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $self->release_data or return 52 1 53
111 52 return $row->{rocm};
112 }
113  
114 40 1;
115  
116 __END__
« lib/Rex/GPU/NVIDIA/Setup/Rpm.pm ↑ Summary lib/Rex/GPU/NVIDIA/Setup/SUSE.pm »