fix(xunix): improve handling of gpu library mounts#129
Merged
Conversation
johnstcn
commented
Mar 6, 2025
Comment on lines
+96
to
+117
| t.Run("EmptyHostUsrLibDir", func(t *testing.T) { | ||
| t.Parallel() | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| t.Cleanup(cancel) | ||
| emptyUsrLibDir := t.TempDir() | ||
|
|
||
| // Start the envbox container. | ||
| ctID := startEnvboxCmd(ctx, t, integrationtest.UbuntuImage, "root", | ||
| "-v", emptyUsrLibDir+":/var/coder/usr/lib", | ||
| "--env", "CODER_ADD_GPU=true", | ||
| "--env", "CODER_USR_LIB_DIR=/var/coder/usr/lib", | ||
| "--runtime=nvidia", | ||
| "--gpus=all", | ||
| ) | ||
|
|
||
| ofs := outerFiles(ctx, t, ctID, "/usr/lib/x86_64-linux-gnu/libnv*") | ||
| // Assert invariant: the outer container has the files we expect. | ||
| require.NotEmpty(t, ofs, "failed to list outer container files") | ||
| // Assert that expected files are available in the inner container. | ||
| assertInnerFiles(ctx, t, ctID, "/usr/lib/x86_64-linux-gnu/libnv*", ofs...) | ||
| assertInnerNvidiaSMI(ctx, t, ctID) | ||
| }) |
Member
Author
There was a problem hiding this comment.
review: this tests that we can get by with no extra files in CODER_USR_LIB_DIR
johnstcn
commented
Mar 6, 2025
Comment on lines
+125
to
+129
| if !gpuExtraRegex.MatchString(path) { | ||
| return nil | ||
| } | ||
|
|
||
| if !sharedObjectRegex.MatchString(path) { |
Member
Author
There was a problem hiding this comment.
review: this makes the control flow a little easier to read; I accidentally removed this but it still performs an important task
johnstcn
commented
Mar 6, 2025
| gpuExtraRegex = regexp.MustCompile("(?i)(libgl|nvidia|vulkan|cuda)") | ||
| gpuEnvRegex = regexp.MustCompile("(?i)nvidia") | ||
| gpuMountRegex = regexp.MustCompile(`(?i)(nvidia|vulkan|cuda)`) | ||
| gpuExtraRegex = regexp.MustCompile(`(?i)(libgl(e|sx|\.)|nvidia|vulkan|cuda)`) |
Member
Author
There was a problem hiding this comment.
review: modified this regex to hopefully match the right things and not the wrong things
sreya
approved these changes
Mar 6, 2025
deansheather
reviewed
Mar 7, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes some issues Bjorn found when testing the changes in #127 as well as some other lingering issues I'd noticed:
We had been mounting in the mounts to e.g.
libnvidia-ml.so.550.90.07but not the symlinks, as those do not show up as mounts:This modifies the behaviour of
xunix.GPUsto also return the symlinks to those driver files, so that we also mount them inside the inner container.gpuExtraRegexwill search for files matching the expression(?i)(libgl|nvidia|vulkan|cuda). It turns out this will also matchlibglib-X.Y.so. This is something we want to avoid, as it can causednfto break when running Redhat-based distros in the inner container. Shout out to Bjorn for spotting this!NOTE: as these integration tests do not run automatically in CI, you will need to run them manually on a physical machine that has the NVidia container runtime installed: