Skip to content

Commit a02f557

Browse files
committed
[Build] Install the NVIDIA driver and CUDA toolkit from the distribution package manager using NVIDIA local repo packages instead of the run file installers.
1 parent 0d1c5b3 commit a02f557

38 files changed

Lines changed: 1322 additions & 705 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
1414

1515

1616
**CHANGES**
17+
- Install the NVIDIA driver and CUDA toolkit from the distribution package manager using NVIDIA local repo packages instead of the run file installers.
1718
- In GPU Health Check, skip DCGM diagnostics when NVIDIA MIG is enabled because dcgmi diag does not support MIG.
1819

1920
**CHANGES**

cookbooks/aws-parallelcluster-platform/kitchen.platform-install.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ suites:
110110
- resource:package_repos
111111
- 'resource:package { "package_name": "dkms" }'
112112
- resource:build_tools
113+
- resource:nvidia_repo:add
113114
cluster:
114115
nvidia:
115116
enabled: true
@@ -142,8 +143,9 @@ suites:
142143
- resource:package_repos
143144
- 'resource:package { "package_name": "dkms" }'
144145
- resource:build_tools
146+
- resource:nvidia_repo:add
145147
- resource:nvidia_driver
146-
- recipe:aws-parallelcluster-platform::cuda
148+
- resource:nvidia_cuda
147149
cluster:
148150
nvidia:
149151
enabled: true
@@ -263,18 +265,20 @@ suites:
263265
- name: nvidia_cuda
264266
run_list:
265267
- recipe[aws-parallelcluster-tests::setup]
266-
- recipe[aws-parallelcluster-platform::cuda]
268+
- recipe[aws-parallelcluster-tests::test_resource]
267269
verifier:
268270
controls:
269271
- /tag:install_.*cuda/
270272
driver:
271273
# nvidia_driver can be executed only on a graphic EC2 instance example: g5.xlarge(x86_86) or g5g.xlarge(aarm64)
272274
instance_type: g4dn.2xlarge
273275
attributes:
276+
resource: nvidia_cuda
274277
dependencies:
275278
- resource:package_repos
276279
- 'resource:package { "package_name": "dkms" }'
277280
- resource:build_tools
281+
- resource:nvidia_repo:add
278282
cluster:
279283
nvidia:
280284
enabled: true
Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +0,0 @@
1-
# frozen_string_literal: true
2-
3-
#
4-
# Cookbook:: aws-parallelcluster
5-
# Recipe:: cuda
6-
#
7-
# Copyright:: 2013-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8-
#
9-
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
10-
# License. A copy of the License is located at
11-
#
12-
# http://aws.amazon.com/apache2.0/
13-
#
14-
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
15-
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
16-
# limitations under the License.
17-
18-
return unless nvidia_enabled?
19-
20-
# Cuda installer from https://developer.nvidia.com/cuda-toolkit-archive
21-
# Cuda installer naming: cuda_11.8.0_520.61.05_linux
22-
23-
cuda_full_version = node['cluster']['nvidia']['cuda']['version']
24-
cuda_parts = cuda_full_version.split('.')
25-
cuda_version = "#{cuda_parts[0]}.#{cuda_parts[1]}"
26-
cuda_version_suffix = node['cluster']['nvidia']['cuda']['driver_version_suffix']
27-
cuda_samples_version = cuda_version
28-
cuda_arch = arm_instance? ? 'linux_sbsa' : 'linux'
29-
cuda_url = "#{node['cluster']['nvidia']['cuda']['base_url']}/cuda_#{cuda_full_version}_#{cuda_version_suffix}_#{cuda_arch}.run"
30-
cuda_samples_url = "#{node['cluster']['nvidia']['cuda']['samples_base_url']}/v#{cuda_samples_version}.tar.gz"
31-
tmp_cuda_run = '/tmp/cuda.run'
32-
tmp_cuda_sample_archive = '/tmp/cuda-sample.tar.gz'
33-
34-
# Save resolved CUDA versions to .default so InSpec/build-image tests which run during ParallelClusterTestComponent see them (mirrors Nvidia driver).
35-
node.default['cluster']['nvidia']['cuda']['version'] = cuda_full_version
36-
node.default['cluster']['nvidia']['cuda_samples_version'] = cuda_samples_version
37-
node_attributes 'Save cuda and cuda samples versions for InSpec tests'
38-
39-
# Get CUDA run file
40-
remote_file tmp_cuda_run do
41-
source cuda_url
42-
mode '0755'
43-
retries 3
44-
retry_delay 5
45-
not_if { ::File.exist?("/usr/local/cuda-#{cuda_version}") }
46-
end
47-
48-
# Install CUDA driver
49-
bash 'cuda.run advanced' do
50-
user 'root'
51-
group 'root'
52-
cwd '/tmp'
53-
code <<-CUDA
54-
set -e
55-
mkdir /cuda-install
56-
./cuda.run --silent --toolkit --samples --tmpdir=/cuda-install
57-
rm -rf /cuda-install
58-
rm -f /tmp/cuda.run
59-
CUDA
60-
creates "/usr/local/cuda-#{cuda_version}"
61-
end
62-
63-
# Get CUDA Sample Files
64-
remote_file tmp_cuda_sample_archive do
65-
source cuda_samples_url
66-
mode '0644'
67-
retries 3
68-
retry_delay 5
69-
not_if { ::File.exist?("/usr/local/cuda-#{cuda_version}/samples") }
70-
end
71-
72-
# Unpack CUDA Samples
73-
bash 'cuda.sample install' do
74-
user 'root'
75-
group 'root'
76-
cwd '/tmp'
77-
code <<-CUDA
78-
set -e
79-
tar xf "/tmp/cuda-sample.tar.gz" --directory "/usr/local/"
80-
rm -f "/tmp/cuda-sample.tar.gz"
81-
CUDA
82-
creates "/usr/local/cuda-#{cuda_version}/samples"
83-
end

cookbooks/aws-parallelcluster-platform/recipes/install/nvidia_install.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
# Register the NVIDIA local repos (driver and CUDA) up front so that the
19+
# nvidia_driver and nvidia_cuda resources can install their packages from them.
20+
# Versions and URLs default to node attributes and can be overridden there.
21+
nvidia_repo 'Install NVIDIA local repos'
22+
1823
nvidia_driver 'Install Nvidia driver'
1924

20-
include_recipe "aws-parallelcluster-platform::cuda"
25+
nvidia_cuda 'Install Nvidia CUDA'
2126

2227
gdrcopy 'Install Nvidia gdrcopy'
2328

@@ -28,3 +33,8 @@
2833
nvidia_dcgm 'install Nvidia datacenter-gpu-manager'
2934

3035
nvidia_imex 'Install nvidia-imex'
36+
37+
# Remove the NVIDIA local repos now that all NVIDIA packages have been installed
38+
nvidia_repo 'Remove NVIDIA local repos' do
39+
action :remove
40+
end

cookbooks/aws-parallelcluster-platform/resources/fabric_manager/partial/_fabric_manager_common.rb

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
action :setup do
2222
return unless _fabric_manager_enabled
2323

24-
# Share fabric manager package and version with InSpec tests
24+
already_installed = fabric_manager_installed?
25+
26+
# Always expose the package name to InSpec. Record the configured version only
27+
# when pcluster installs it, so a Fabric Manager shipped by the base image
28+
# (e.g. DLAMI) is only checked for presence, not for pcluster's version, and is
29+
# left untouched.
2530
node.default['cluster']['nvidia']['fabricmanager']['package'] = fabric_manager_package
26-
node.default['cluster']['nvidia']['fabricmanager']['version'] = fabric_manager_version
31+
node.default['cluster']['nvidia']['fabricmanager']['version'] = fabric_manager_version unless already_installed
2732
node_attributes "dump node attributes"
2833

29-
action_install_package
34+
action_install_package unless already_installed
3035
end
3136

3237
action :configure do
@@ -40,8 +45,15 @@
4045
end
4146

4247
def _fabric_manager_enabled
43-
# NVIDIA Fabric Manager not present on ARM
44-
!arm_instance? && _nvidia_enabled
48+
# NVIDIA Fabric Manager not present on ARM, and it requires the NVIDIA driver.
49+
# Install only when NVIDIA is enabled and the driver is already installed.
50+
!arm_instance? && _nvidia_enabled && nvidia_installed?
51+
end
52+
53+
# True if Fabric Manager is already installed (e.g. shipped by the base image
54+
# such as the DLAMI). nv-fabricmanager is installed to /usr/bin on all platforms.
55+
def fabric_manager_installed?
56+
::File.exist?('/usr/bin/nv-fabricmanager')
4557
end
4658

4759
def _nvidia_enabled
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "LICENSE.txt" file accompanying this file.
12+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
13+
# See the License for the specific language governing permissions and limitations under the License.
14+
15+
provides :nvidia_cuda, platform: 'amazon' do |node|
16+
node['platform_version'].to_i == 2023
17+
end
18+
19+
use 'partial/_nvidia_cuda_common.rb'
20+
use 'partial/_nvidia_cuda_install_rhel.rb'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "LICENSE.txt" file accompanying this file.
12+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
13+
# See the License for the specific language governing permissions and limitations under the License.
14+
15+
provides :nvidia_cuda, platform: 'redhat' do |node|
16+
node['platform_version'].to_i >= 8
17+
end
18+
19+
use 'partial/_nvidia_cuda_common.rb'
20+
use 'partial/_nvidia_cuda_install_rhel.rb'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "LICENSE.txt" file accompanying this file.
12+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
13+
# See the License for the specific language governing permissions and limitations under the License.
14+
15+
provides :nvidia_cuda, platform: 'rocky' do |node|
16+
node['platform_version'].to_i >= 8
17+
end
18+
19+
use 'partial/_nvidia_cuda_common.rb'
20+
use 'partial/_nvidia_cuda_install_rhel.rb'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright:: 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "LICENSE.txt" file accompanying this file.
12+
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
13+
# See the License for the specific language governing permissions and limitations under the License.
14+
15+
provides :nvidia_cuda, platform: 'ubuntu' do |node|
16+
node['platform_version'].to_i >= 22
17+
end
18+
19+
use 'partial/_nvidia_cuda_common.rb'
20+
use 'partial/_nvidia_cuda_install_debian.rb'

0 commit comments

Comments
 (0)