-
Notifications
You must be signed in to change notification settings - Fork 32
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
new branch with linux header changes #65
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -63,39 +63,40 @@ _resolve_kernel_version() { | |||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
# Install the kernel modules header/builtin/order files and generate the kernel version string. | ||||||||||||||||||||
_install_prerequisites() ( | ||||||||||||||||||||
_install_prerequisites() { | ||||||||||||||||||||
local tmp_dir=$(mktemp -d) | ||||||||||||||||||||
|
||||||||||||||||||||
trap "rm -rf ${tmp_dir}" EXIT | ||||||||||||||||||||
cd ${tmp_dir} | ||||||||||||||||||||
|
||||||||||||||||||||
if [ "${PERSIST_DRIVER}" = false ]; then | ||||||||||||||||||||
rm -rf /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure why cleaning up this directory is required on every driver container instantiation. @shivamerla @tariq1890 would you happen to know why? If we can remove this, then we no longer need this conditional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On container startup, if we do not mount
Based on this observation, what are your thoughts on my below proposal?
|
||||||||||||||||||||
fi | ||||||||||||||||||||
|
||||||||||||||||||||
if [ ! -d "/usr/src/linux-headers-$(uname -r)/" ]; then | ||||||||||||||||||||
echo "Installing Linux kernel headers..." | ||||||||||||||||||||
apt-get -qq install --no-install-recommends linux-headers-${KERNEL_VERSION} > /dev/null | ||||||||||||||||||||
fi | ||||||||||||||||||||
Comment on lines
+76
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An observation -- if we mount |
||||||||||||||||||||
|
||||||||||||||||||||
echo ${KERNEL_VERSION} > version | ||||||||||||||||||||
|
||||||||||||||||||||
rm -rf /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
echo "Generating Linux kernel version string..." | ||||||||||||||||||||
|
||||||||||||||||||||
mkdir -p /lib/modules/${KERNEL_VERSION}/proc | ||||||||||||||||||||
|
||||||||||||||||||||
echo "Installing Linux kernel headers..." | ||||||||||||||||||||
apt-get -qq install --no-install-recommends linux-headers-${KERNEL_VERSION} > /dev/null | ||||||||||||||||||||
|
||||||||||||||||||||
echo "Installing Linux kernel module files..." | ||||||||||||||||||||
apt-get -qq download linux-image-${KERNEL_VERSION} && dpkg -x linux-image*.deb . | ||||||||||||||||||||
{ apt-get -qq download linux-modules-${KERNEL_VERSION} && dpkg -x linux-modules*.deb . || true; } 2> /dev/null | ||||||||||||||||||||
Comment on lines
-79
to
-80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the |
||||||||||||||||||||
mv lib/modules/${KERNEL_VERSION}/modules.* /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
mv lib/modules/${KERNEL_VERSION}/kernel /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
depmod ${KERNEL_VERSION} | ||||||||||||||||||||
|
||||||||||||||||||||
echo "Generating Linux kernel version string..." | ||||||||||||||||||||
mv version /lib/modules/${KERNEL_VERSION}/proc | ||||||||||||||||||||
|
||||||||||||||||||||
ls -1 boot/vmlinuz-* | sed 's/\/boot\/vmlinuz-//g' - > version | ||||||||||||||||||||
if [ -z "$(<version)" ]; then | ||||||||||||||||||||
echo "Could not locate Linux kernel version string" >&2 | ||||||||||||||||||||
return 1 | ||||||||||||||||||||
Comment on lines
-87
to
-90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shivamerla after reviewing this again, do we even really require to install the Based on my understanding, I think we can remove this code block entirely in all cases and never install the |
||||||||||||||||||||
if [ "${PERSIST_DRIVER}" = false ]; then | ||||||||||||||||||||
mv lib/modules/${KERNEL_VERSION}/modules.* /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
mv lib/modules/${KERNEL_VERSION}/kernel /lib/modules/${KERNEL_VERSION} | ||||||||||||||||||||
depmod ${KERNEL_VERSION} | ||||||||||||||||||||
Comment on lines
+90
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, these commands won't work as they require that the linux-image and linux-modules deb packages were downloaded and extracted locally first.
Comment on lines
+89
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on my comment https://github.com/NVIDIA/gpu-driver-container/pull/65/files#r1681872260 I would recommend the following change:
Suggested change
|
||||||||||||||||||||
fi | ||||||||||||||||||||
mv version /lib/modules/${KERNEL_VERSION}/proc | ||||||||||||||||||||
) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
# Cleanup the prerequisites installed above. | ||||||||||||||||||||
_remove_prerequisites() { | ||||||||||||||||||||
if [ "${PACKAGE_TAG:-}" != "builtin" ]; then | ||||||||||||||||||||
apt-get -qq purge linux-headers-${KERNEL_VERSION} > /dev/null | ||||||||||||||||||||
apt-get -qq purge linux-headers-${KERNEL_VERSION} > /dev/null || true | ||||||||||||||||||||
# TODO remove module files not matching an existing driver package. | ||||||||||||||||||||
fi | ||||||||||||||||||||
} | ||||||||||||||||||||
|
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.
Ideally we should not be relying on the
PERSIST_DRIVER
environment variable as that feature is not introduced in this PR.