Skip to content
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

fix(remount): relocate libraries along with their symlinks #255

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

maxbrunet
Copy link
Contributor

This PR adds:

  1. Look up the library directory, the value differs for Debian-based distros (the initial envbuilder image is non-Debian, but the final image may be Debian)
  2. Find the symlinks pointing to mounts in the library directory
  3. Temporarily move the library symlinks pointing to mounts to the magic directory while relocating the mounts
  4. Look up the new library directory (in case it has changed)
  5. Move back the library symlinks and mounts to the new library directory

After that the container should behave like a regular container created by the NVIDIA container runtime. Of course/unfortunately, the process of mounting/unmounting requires GPU containers to run with privileges:

Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required to mount/umount filesystems.

https://www.man7.org/linux/man-pages/man2/mount.2.html
https://www.man7.org/linux/man-pages/man2/umount.2.html

The logic is not generalized to any symlinks or any directories, it only aims at providing compatibility with the NVIDIA container runtime for now.

More context can be found in this comment #143 (comment)

Tested with the following images:

  • docker.io/library/debian:bookworm
  • docker.io/library/fedora:40
  • nvcr.io/nvidia/pytorch:24.05-py3

Closes #143

internal/ebutil/libs.go Show resolved Hide resolved
internal/ebutil/libs.go Outdated Show resolved Hide resolved
internal/ebutil/remount.go Show resolved Hide resolved
internal/ebutil/libs_ppc64le.go Outdated Show resolved Hide resolved
internal/ebutil/remount.go Outdated Show resolved Hide resolved
internal/ebutil/remount.go Outdated Show resolved Hide resolved
internal/ebutil/remount.go Outdated Show resolved Hide resolved
internal/ebutil/libs.go Outdated Show resolved Hide resolved
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution!

I validated this fix on a Fedora 40 system with the NVidia runtime etc. installed (so no /usr/lib/x86_64-linux-gnu), using both Docker (v27.0.2) and K3s (v1.29.6).

(Edit: for posterity, also verified working on an AL2 EKS cluster.)

In both cases, I was able to successfully build the image nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda10.2, run nvidia-smi and /tmp/vectorAdd.

My only things I would like to see changed are:

  • More commenting for future readers/code-spelunkers
  • Remove references to PPC arch; I don't know if we will ever support this.

There may also be a similar workaround needed for AMD/Vulkan cards, but this can be tested separately.

@maxbrunet maxbrunet force-pushed the fix/remount/relocate-libs branch from 0997cbd to 07d0f1c Compare July 1, 2024 16:40
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

@johnstcn johnstcn merged commit 46a78fb into coder:main Jul 2, 2024
4 checks passed
@maxbrunet maxbrunet deleted the fix/remount/relocate-libs branch July 2, 2024 18:30
johnstcn pushed a commit that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate GPU support
3 participants