-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nvidia] On Ubuntu22, install the NVIDIA driver using the gcc version…
… used to compile the kernel. This is required because, NVIDIA driver must be compiled with the same gcc version used by the kernel. If this is not the case, the NVIDIA driver installation would fail a compiler version check. On newer version of Ubuntu22.04 (kernel 6.8+), the kernel is compiled with gcc-12, however gcc-11 is installed as default version by build-essentials, making this change necessary. Signed-off-by: Giacomo Marciani <[email protected]>
- Loading branch information
Showing
6 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cookbooks/aws-parallelcluster-platform/resources/nvidia_driver/nvidia_driver_ubuntu22.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright:: 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. | ||
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. | ||
# See the License for the specific language governing permissions and limitations under the License. | ||
|
||
provides :nvidia_driver, platform: 'ubuntu' do |node| | ||
node['platform_version'].to_i == 22 | ||
end | ||
|
||
use 'partial/_nvidia_driver_common.rb' | ||
|
||
def rebuild_initramfs? | ||
true | ||
end | ||
|
||
def compiler_path | ||
gcc_major_version = gcc_major_version_used_by_kernel | ||
|
||
# If the gcc version used to compile the kernel cannot be detected, | ||
# empty string is returned, meaning that the NVIDIA driver will be compiled | ||
# using the system default compiler. | ||
return "" if gcc_major_version.nil? | ||
|
||
"CC=/usr/bin/gcc-#{gcc_major_version}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
cookbooks/aws-parallelcluster-shared/spec/unit/libraries/helpers_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require_relative '../../../libraries/helpers' | ||
require 'spec_helper' | ||
|
||
describe 'gcc_major_version_used_by_kernel' do | ||
|
||
let(:cmd) { "awk '{print $8}' /proc/version | tr -d ',' | cut -d '.' -f 1" } | ||
let(:shellout) { double(run_command: nil, error!: nil, stdout: '', stderr: '', exitstatus: 0, live_stream: '') } | ||
|
||
context 'when gcc version can be detected' do | ||
|
||
before do | ||
allow(Mixlib::ShellOut).to receive(:new).with(cmd, any_args).and_return(shellout) | ||
allow(shellout).to receive(:stdout).and_return("1") | ||
end | ||
|
||
it 'returns the correct gcc major version' do | ||
result = gcc_major_version_used_by_kernel | ||
expect(result).to eq("1") | ||
end | ||
end | ||
|
||
context 'when gcc version cannot be detected' do | ||
|
||
before do | ||
allow(Mixlib::ShellOut).to receive(:new).with(cmd, any_args).and_raise(Mixlib::ShellOut::ShellCommandFailed) | ||
end | ||
|
||
it 'returns an empty string' do | ||
result = gcc_major_version_used_by_kernel | ||
expect(result).to eq("") | ||
end | ||
end | ||
end |