Skip to content

Commit d1f9aad

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 5a3258d commit d1f9aad

39 files changed

Lines changed: 1377 additions & 684 deletions

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
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**
@@ -30,7 +31,7 @@ via custom Slurm settings or the cluster name contains upper-case letters.
3031
- Fix compute node bootstrap hanging without a clear error when the compute subnet cannot reach DynamoDB.
3132
- Fix login nodes not mounting `/opt/parallelcluster/shared` when EFS is used as the internal shared storage type.
3233
- Fix SELinux not actually being disabled on RHEL-family OSes (kernels >= 6.4) due to a [deprecated mechanism](https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-runtime-disable) being silently ignored by newer kernels.
33-
- Fix `build-image` failure by skipping installation of `gdrcopy` and `dcgm` if parent image has an existing installed version.
34+
- Fix `build-image` failure by skipping installation of `fabric-manager`, `gdrcopy` and `dcgm` if parent image has an existing installed version.
3435

3536
**DEPRECATIONS**
3637
- Amazon Linux 2 is no longer supported.

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

cookbooks/aws-parallelcluster-platform/libraries/nvidia.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ def nvidia_enabled?
1414
['yes', true, 'true'].include?(node['cluster']['nvidia']['enabled'])
1515
end
1616

17+
# Convert a full CUDA version to its 'major-minor' dashed form used in CUDA repo
18+
# and package names, e.g. '13-0' for '13.0.2'. The patch level (the '.2') is
19+
# intentionally dropped because CUDA repos and packages are keyed on major-minor
20+
# only (e.g. 'cuda-repo-rhel9-13-0-local', 'cuda-toolkit-13-0').
21+
def cuda_version_dash(cuda_version)
22+
major, minor = cuda_version.split('.')
23+
"#{major}-#{minor}"
24+
end
25+
1726
# Whether a base_url attribute still points to the default ParallelCluster artifacts location.
1827
# Used by: fabric manager, dcgm, nvlsm, enroot (caps).
1928
# Limitation: this check assumes attribute precedence resolves at attribute-load time
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
action :setup do
2222
return unless _fabric_manager_enabled
23+
return if fabric_manager_installed?
2324

2425
# Share fabric manager package and version with InSpec tests
2526
node.default['cluster']['nvidia']['fabricmanager']['package'] = fabric_manager_package
@@ -44,6 +45,12 @@ def _fabric_manager_enabled
4445
!arm_instance? && _nvidia_enabled
4546
end
4647

48+
# True if Fabric Manager is already installed (e.g. shipped by the base image
49+
# such as the DLAMI). nv-fabricmanager is installed to /usr/bin on all platforms.
50+
def fabric_manager_installed?
51+
::File.exist?('/usr/bin/nv-fabricmanager')
52+
end
53+
4754
def _nvidia_enabled
4855
nvidia_enabled.nil? ? ['yes', true, 'true'].include?(node['cluster']['nvidia']['enabled']) : nvidia_enabled
4956
end
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)