-
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
7 changed files
with
136 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
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
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
# 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 set_compiler? | ||
true | ||
end | ||
|
||
def compiler_version | ||
'gcc' | ||
end | ||
|
||
def extra_packages | ||
%w() | ||
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
26 changes: 26 additions & 0 deletions
26
cookbooks/aws-parallelcluster-shared/libraries/ubuntu/helpers.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,26 @@ | ||
# 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. | ||
|
||
def gcc_major_version_used_by_kernel | ||
# Detects the gcc major version used to compile the kernel, e.g. 12. | ||
# If the version cannot be detected, nil is returned. | ||
# (Tested only on Ubuntu) | ||
begin | ||
gcc_major_version = shell_out("cat /proc/version | grep -Eo 'gcc-[0-9]+' | cut -d '-' -f 2").stdout.strip | ||
rescue => error | ||
Chef::Log.error("Cannot detect gcc version used to compile the kernel: #{error}") | ||
return "" | ||
end | ||
Chef::Log.info("Detected version of gcc used to compile the kernel is: #{gcc_major_version}") | ||
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
30 changes: 30 additions & 0 deletions
30
cookbooks/aws-parallelcluster-shared/spec/unit/libraries/ubuntu/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,30 @@ | ||
require_relative '../../../../libraries/ubuntu/helpers' | ||
require 'spec_helper' | ||
|
||
describe 'gcc_major_version_used_by_kernel' do | ||
let(:cmd) { "cat /proc/version | grep -Eo 'gcc-[0-9]+' | cut -d '-' -f 2" } | ||
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 |