-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
libnvidia-container: include binaries from driver package #372320
Merged
ConnorBaker
merged 2 commits into
NixOS:master
from
msanft:msanft/libnvidia-container/driver-bins
Jan 14, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
|
@@ -3,42 +3,26 @@ From: Moritz Sanft <[email protected]> | |
Date: Fri, 20 Dec 2024 16:37:07 +0100 | ||
Subject: [PATCH] nvc: nvidia-docker-compatible binary lookups | ||
|
||
This patch maintains compatibility with NixOS' `virtualisation.docker.enableNvidia` option (which is to be removed soon), while also enabling supplying a custom PATH, to work with the modern CDI-based approach. | ||
This patch maintains compatibility with NixOS' `virtualisation.docker.enableNvidia` option (which is to be removed soon), while also including the driver package's path, to work with the modern CDI-based approach. | ||
--- | ||
src/nvc_info.c | 16 ++++++++++++++-- | ||
1 file changed, 14 insertions(+), 2 deletions(-) | ||
src/nvc_info.c | 5 ++++- | ||
1 file changed, 4 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/nvc_info.c b/src/nvc_info.c | ||
index cf4b1905fd2127c28ee16649501be122d3be5261..2ab552860ef98879b76398a6f9be95f07b2c8a4a 100644 | ||
index cf4b1905fd2127c28ee16649501be122d3be5261..cdfa19721bc913d8e2adb96d106cd65ee6111623 100644 | ||
--- a/src/nvc_info.c | ||
+++ b/src/nvc_info.c | ||
@@ -243,16 +243,28 @@ static int | ||
find_binary_paths(struct error *err, struct dxcore_context* dxcore, struct nvc_driver_info* info, | ||
const char *root, const char * const bins[], size_t size) | ||
{ | ||
- char *env, *ptr; | ||
+ char *env, *ptr, *os_path; | ||
const char *dir; | ||
char tmp[PATH_MAX]; | ||
@@ -249,10 +249,13 @@ find_binary_paths(struct error *err, struct dxcore_context* dxcore, struct nvc_d | ||
char path[PATH_MAX]; | ||
int rv = -1; | ||
|
||
- if ((env = secure_getenv("PATH")) == NULL) { | ||
+ if ((os_path = secure_getenv("PATH")) == NULL) { | ||
+ // TODO: Remove this patch once `virtualisation.docker.enableNvidia` is removed from NixOS. | ||
+ // It only exists to maintain compatibility with the old nvidia-docker package. | ||
+ if ((env = "/run/nvidia-docker/bin:/run/nvidia-docker/extras/bin:@driverLink@/bin") == NULL) { | ||
error_setx(err, "environment variable PATH not found"); | ||
return (-1); | ||
} | ||
Comment on lines
+20
to
25
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. Unless you wanted to keep the |
||
+ | ||
+ // TODO: Remove this patch once `virtualisation.docker.enableNvidia` is removed from NixOS. | ||
+ // It only exists to maintain compatibility with the old nvidia-docker package. | ||
+ int p_rv = snprintf(env, PATH_MAX, "/run/nvidia-docker/bin:/run/nvidia-docker/extras/bin:%s", os_path); | ||
+ if (p_rv >= PATH_MAX) { | ||
+ error_setx(err, "PATH environment variable too long"); | ||
+ return (-1); | ||
+ } else if (p_rv < 0) { | ||
+ error_setx(err, "error setting PATH environment variable"); | ||
+ return (-1); | ||
+ } | ||
+ | ||
if ((env = ptr = xstrdup(err, env)) == NULL) | ||
return (-1); | ||
|
This file contains 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
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.
Why do late-binding for nixos (
/run
paths) but not other systems (e.g. viaPATH
), and why not just always use the early-bound@driverLink@/bin
?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.
If I'm not mistaken,
/run/nvidia-docker/bin
are remnants ofvirtualisation.docker.enableNvidia
. This patch goes back to always using that, while adding@driverLink@/bin
. I had added additional support forPATH
before (#366855), but things went south there as I introduced a bug. Looking back at that, I decided to go back to a static path, which I did in this PR.