-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(neuron): install aws-neuronx-dkms-2.21 at boot on inf1 #2579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+87
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
templates/al2023/runtime/gpu/neuron-package-install.service
This file contains hidden or 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,13 @@ | ||
| [Unit] | ||
| Description=Install Neuron packages | ||
| # Run before cloud-init so packages are installed | ||
| # before user data that may query the installed information | ||
| Before=cloud-init.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/etc/eks/neuron-package-install.sh | ||
| RemainAfterExit=true | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
This file contains hidden or 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,49 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o nounset | ||
|
|
||
| readonly PACKAGE_CACHE_PATH="/var/cache/eks/packages" | ||
|
|
||
| readonly AMAZON_VENDOR_CODE="1d0f" | ||
| # Based on https://github.com/aws-neuron/aws-neuron-driver/blob/fca19f7df31b44cbbffaf121230a66df6f59d118/neuron_device.h#L36-L39 | ||
| readonly INF1_DEVICE_IDS=("7064" "7065" "7066" "7067") | ||
|
|
||
| function is-inf1() { | ||
| for DEVICE_ID in "${INF1_DEVICE_IDS[@]}"; do | ||
| MATCHED_DEVICES=$(lspci -d "${AMAZON_VENDOR_CODE}:${DEVICE_ID}" | wc -l) | ||
| if [[ "$MATCHED_DEVICES" -gt 0 ]]; then | ||
| return 0 | ||
| fi | ||
| done | ||
|
|
||
| return 1 | ||
| } | ||
|
|
||
| # the aws-neuronx-dkms module has a pre-install script that calls | ||
| # on update-pciids, which will hang if called from a node | ||
| # that cannot reach https://pci-ids.ucw.cz/v2.2/pci.ids | ||
| # the values pulled by the install at build time can be used | ||
| # in lieu of this | ||
| function update-pciids() { | ||
| echo "update-pciids called: doing nothing" | ||
| } | ||
|
|
||
| function installed-neuron-driver-version() { | ||
| rpm -q aws-neuronx-dkms --queryformat '%{VERSION}' | ||
| } | ||
|
|
||
| if is-inf1 && [[ $(installed-neuron-driver-version) != 2.21.* ]]; then | ||
| echo "downgrading driver to 2.21" | ||
| # "dnf downgrade" would fail because the post remove script for the package | ||
| # does not fully remove the module, and then the post install script for the | ||
| # downgraded version fails because of an attempt to probe an older version of | ||
| # a loaded module without --force. relying on the rpm cli directly makes the | ||
| # operations more intuitive | ||
| export -f update-pciids | ||
| rpm --erase aws-neuronx-dkms | ||
| rpm -i "${PACKAGE_CACHE_PATH}/aws-neuronx-dkms-2.21.*.rpm" | ||
| else | ||
| echo "nothing to do!" | ||
| fi |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need some ordering relative to user data script execution to ensure deterministic behavior, each has it's trade-offs.