From: Hannes Duerr <h.duerr@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmx-nvidia-vgpu-helper 2/2] add script to help with the installation of the nvidia vgpu dependencies
Date: Wed, 20 Nov 2024 12:26:10 +0100 [thread overview]
Message-ID: <20241120112610.160234-3-h.duerr@proxmox.com> (raw)
In-Reply-To: <20241120112610.160234-1-h.duerr@proxmox.com>
The script should help with the dependency installation for the nvidia
vgpu driver, also if the driver is already installed but the system has
been updated
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
pve-install-nvidia-vgpu-deps | 66 ++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100755 pve-install-nvidia-vgpu-deps
diff --git a/pve-install-nvidia-vgpu-deps b/pve-install-nvidia-vgpu-deps
new file mode 100755
index 0000000..fc0856e
--- /dev/null
+++ b/pve-install-nvidia-vgpu-deps
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use PVE::Tools qw(run_command);
+use AptPkg::Cache;
+
+my @apt_install = qw(apt-get --no-install-recommends -o Dpkg:Options::=--force-confnew install --);
+my @dependencies = qw(dkms libc6-dev);
+my @missing_packages;
+
+die "Please execute the script with root privileges\n" if $>;
+
+my $apt_cache = AptPkg::Cache->new();
+die "unable to initialize AptPkg::Cache\n" if !$apt_cache;
+
+sub package_is_installed {
+ my ($package) = @_;
+ my $p = $apt_cache->{$package};
+ if (!defined($p->{CurrentState}) || $p->{CurrentState} ne "Installed") {
+ push(@missing_packages, $package);
+ }
+}
+
+foreach my $dependency (@dependencies) {
+ package_is_installed($dependency);
+}
+
+
+my $running_kernel;
+run_command( ['/usr/bin/uname', '-r' ],
+ outfunc => sub { $running_kernel = shift } );
+
+my $default_major_minor_version;
+run_command(['/usr/bin/dpkg-query', '-f', '${Depends}', '-W', 'proxmox-default-kernel'],
+ outfunc => sub { $default_major_minor_version = shift } );
+
+my $default_full_version;
+run_command(['/usr/bin/dpkg-query', '-f', '${Version}', '-W', $default_major_minor_version],
+ outfunc => sub { $default_full_version = shift } );
+
+if ($running_kernel =~ /$default_full_version-pve/) {
+ print "You are running the proxmox default kernel `proxmox-kernel-$running_kernel`\n";
+ package_is_installed("proxmox-default-headers");
+} elsif ($running_kernel =~ /pve/) {
+ print "You are running the non default proxmox kernel `proxmox-kernel-$running_kernel`\n";
+ package_is_installed("proxmox-headers-$running_kernel");
+} else {
+ die "You are not using a proxmox-kernel, please make sure that the appropriate header package is installed.\n";
+}
+
+if (!@missing_packages){
+ print "All required packages are installed, you can continue with the Nvidia vGPU driver installation.\n";
+ exit;
+} else {
+ print "The following packages are missing:\n" . join("\n", @missing_packages) ."\n";
+ print "Would you like to install them now (y/n)?\n";
+}
+
+my $answer = <STDIN>;
+if (defined($answer) && $answer =~ m/^\s*y(?:es)?\s*$/i) {
+ if (system(@apt_install, @missing_packages) != 0) {
+ die "apt failed during the installation: ($?)\n";
+ }
+}
--
2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2024-11-20 11:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 11:26 [pve-devel] [PATCH proxmx-nvidia-vgpu-helper 0/2] reduce setup steps for nvidia vgpu drivers Hannes Duerr
2024-11-20 11:26 ` [pve-devel] [PATCH proxmx-nvidia-vgpu-helper 1/2] debian/control: adjust description and pve-manager dependency Hannes Duerr
2024-11-20 11:26 ` Hannes Duerr [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241120112610.160234-3-h.duerr@proxmox.com \
--to=h.duerr@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox