libnvidia-container: 1.16.2 -> 1.17.2; cleanup (#366855)
This commit is contained in:
+19
-30
@@ -1,22 +1,22 @@
|
||||
From 8799541f99785d2bd881561386676fb0985e939e Mon Sep 17 00:00:00 2001
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
|
||||
Date: Thu, 10 Oct 2024 14:32:42 +0200
|
||||
Subject: [PATCH] fix library resolving
|
||||
Date: Fri, 20 Dec 2024 16:34:50 +0100
|
||||
Subject: [PATCH] ldcache: don't use ldcache
|
||||
|
||||
Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
|
||||
This patch hinders libnvidia-container from using the loader cache, which doesn't get used on NixOS.
|
||||
---
|
||||
src/ldcache.c | 46 +++++++++++++++++-----------------------------
|
||||
src/ldcache.h | 2 +-
|
||||
src/nvc_info.c | 10 +++-------
|
||||
src/nvc_info.c | 8 ++------
|
||||
src/nvc_ldcache.c | 2 +-
|
||||
4 files changed, 22 insertions(+), 38 deletions(-)
|
||||
4 files changed, 21 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/src/ldcache.c b/src/ldcache.c
|
||||
index 38bab055..8cd30a0f 100644
|
||||
index 38bab0553208f66b2866ccea6cdb0faca4357f19..1c4acd52b622be4ca6accdc80da5a6fcf9ae67dd 100644
|
||||
--- a/src/ldcache.c
|
||||
+++ b/src/ldcache.c
|
||||
@@ -108,40 +108,28 @@ ldcache_close(struct ldcache *ctx)
|
||||
|
||||
|
||||
int
|
||||
ldcache_resolve(struct ldcache *ctx, uint32_t arch, const char *root, const char * const libs[],
|
||||
- char *paths[], size_t size, ldcache_select_fn select, void *select_ctx)
|
||||
@@ -27,10 +27,10 @@ index 38bab055..8cd30a0f 100644
|
||||
- int override;
|
||||
+ char dir[PATH_MAX];
|
||||
+ char lib[PATH_MAX];
|
||||
|
||||
|
||||
- h = (struct header_libc6 *)ctx->ptr;
|
||||
memset(paths, 0, size * sizeof(*paths));
|
||||
|
||||
|
||||
- for (uint32_t i = 0; i < h->nlibs; ++i) {
|
||||
- int32_t flags = h->libs[i].flags;
|
||||
- char *key = (char *)ctx->ptr + h->libs[i].key;
|
||||
@@ -74,7 +74,7 @@ index 38bab055..8cd30a0f 100644
|
||||
return (0);
|
||||
}
|
||||
diff --git a/src/ldcache.h b/src/ldcache.h
|
||||
index 33d78dd7..2b087dbc 100644
|
||||
index 33d78dd7e21f65eb696535c115bbd2839a6c67ca..2b087dbca1a6a2946cd495e676a61e956212e3dc 100644
|
||||
--- a/src/ldcache.h
|
||||
+++ b/src/ldcache.h
|
||||
@@ -50,6 +50,6 @@ void ldcache_init(struct ldcache *, struct error *, const char *);
|
||||
@@ -83,10 +83,10 @@ index 33d78dd7..2b087dbc 100644
|
||||
int ldcache_resolve(struct ldcache *, uint32_t, const char *, const char * const [],
|
||||
- char *[], size_t, ldcache_select_fn, void *);
|
||||
+ char *[], size_t, const char*);
|
||||
|
||||
|
||||
#endif /* HEADER_LDCACHE_H */
|
||||
diff --git a/src/nvc_info.c b/src/nvc_info.c
|
||||
index b7b8adfa..d42f2beb 100644
|
||||
index b7b8adfa7c79c326a1acb481a06a05d1463e810f..cf4b1905fd2127c28ee16649501be122d3be5261 100644
|
||||
--- a/src/nvc_info.c
|
||||
+++ b/src/nvc_info.c
|
||||
@@ -217,15 +217,13 @@ find_library_paths(struct error *err, struct dxcore_context *dxcore, struct nvc_
|
||||
@@ -95,7 +95,7 @@ index b7b8adfa..d42f2beb 100644
|
||||
ldcache_init(&ld, err, path);
|
||||
- if (ldcache_open(&ld) < 0)
|
||||
- return (-1);
|
||||
|
||||
|
||||
info->nlibs = size;
|
||||
info->libs = array_new(err, size);
|
||||
if (info->libs == NULL)
|
||||
@@ -104,7 +104,7 @@ index b7b8adfa..d42f2beb 100644
|
||||
- info->libs, info->nlibs, select_libraries_fn, info) < 0)
|
||||
+ info->libs, info->nlibs, info->nvrm_version) < 0)
|
||||
goto fail;
|
||||
|
||||
|
||||
info->nlibs32 = size;
|
||||
@@ -233,13 +231,11 @@ find_library_paths(struct error *err, struct dxcore_context *dxcore, struct nvc_
|
||||
if (info->libs32 == NULL)
|
||||
@@ -114,34 +114,23 @@ index b7b8adfa..d42f2beb 100644
|
||||
+ info->libs32, info->nlibs32, info->nvrm_version) < 0)
|
||||
goto fail;
|
||||
rv = 0;
|
||||
|
||||
|
||||
fail:
|
||||
- if (ldcache_close(&ld) < 0)
|
||||
- return (-1);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
@@ -253,7 +249,7 @@ 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 ((env = "/run/nvidia-docker/bin:/run/nvidia-docker/extras/bin") == NULL) {
|
||||
error_setx(err, "environment variable PATH not found");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
diff --git a/src/nvc_ldcache.c b/src/nvc_ldcache.c
|
||||
index db3b2f69..ae5def43 100644
|
||||
index db3b2f69692270e9058b2e26f18eb31677909d05..ae5def43b4cb3973af3aad55361265173ca938a7 100644
|
||||
--- a/src/nvc_ldcache.c
|
||||
+++ b/src/nvc_ldcache.c
|
||||
@@ -367,7 +367,7 @@ nvc_ldcache_update(struct nvc_context *ctx, const struct nvc_container *cnt)
|
||||
if (validate_args(ctx, cnt != NULL) < 0)
|
||||
return (-1);
|
||||
|
||||
|
||||
- argv = (char * []){cnt->cfg.ldconfig, "-f", "/etc/ld.so.conf", "-C", "/etc/ld.so.cache", cnt->cfg.libs_dir, cnt->cfg.libs32_dir, NULL};
|
||||
+ argv = (char * []){cnt->cfg.ldconfig, "-f", "/tmp/ld.so.conf.nvidia-host", "-C", "/tmp/ld.so.cache.nvidia-host", cnt->cfg.libs_dir, cnt->cfg.libs32_dir, NULL};
|
||||
if (*argv[0] == '@') {
|
||||
/*
|
||||
* We treat this path specially to be relative to the host filesystem.
|
||||
--
|
||||
2.46.0
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
|
||||
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.
|
||||
---
|
||||
src/nvc_info.c | 16 ++++++++++++++--
|
||||
1 file changed, 14 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/nvc_info.c b/src/nvc_info.c
|
||||
index cf4b1905fd2127c28ee16649501be122d3be5261..2ab552860ef98879b76398a6f9be95f07b2c8a4a 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];
|
||||
char path[PATH_MAX];
|
||||
int rv = -1;
|
||||
|
||||
- if ((env = secure_getenv("PATH")) == NULL) {
|
||||
+ if ((os_path = secure_getenv("PATH")) == NULL) {
|
||||
error_setx(err, "environment variable PATH not found");
|
||||
return (-1);
|
||||
}
|
||||
+
|
||||
+ // 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);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
|
||||
Date: Fri, 20 Dec 2024 16:38:55 +0100
|
||||
Subject: [PATCH] nvc: fix struct declaration
|
||||
|
||||
---
|
||||
src/nvcgo.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/nvcgo.c b/src/nvcgo.c
|
||||
index 2e090c9bef83e165dfb722ab27e3287407466173..643504cd485fbe4a89d5959a1adfb69ff6748576 100644
|
||||
--- a/src/nvcgo.c
|
||||
+++ b/src/nvcgo.c
|
||||
@@ -33,7 +33,8 @@
|
||||
void nvcgo_program_1(struct svc_req *, register SVCXPRT *);
|
||||
|
||||
static struct nvcgo_ext {
|
||||
- struct nvcgo;
|
||||
+ struct rpc rpc;
|
||||
+ struct libnvcgo api;
|
||||
bool initialized;
|
||||
void *dl_handle;
|
||||
} global_nvcgo_context;
|
||||
@@ -1,14 +0,0 @@
|
||||
diff --git a/src/nvcgo.c b/src/nvcgo.c
|
||||
index 98789a3..47ad02b 100644
|
||||
--- a/src/nvcgo.c
|
||||
+++ b/src/nvcgo.c
|
||||
@@ -33,7 +33,8 @@
|
||||
void nvcgo_program_1(struct svc_req *, register SVCXPRT *);
|
||||
|
||||
static struct nvcgo_ext {
|
||||
- struct nvcgo;
|
||||
+ struct rpc rpc;
|
||||
+ struct libnvcgo api;
|
||||
bool initialized;
|
||||
void *dl_handle;
|
||||
} global_nvcgo_context;
|
||||
@@ -10,48 +10,52 @@
|
||||
rpcsvc-proto,
|
||||
libtirpc,
|
||||
makeWrapper,
|
||||
substituteAll,
|
||||
removeReferencesTo,
|
||||
replaceVars,
|
||||
go,
|
||||
applyPatches,
|
||||
nvidia-modprobe,
|
||||
}:
|
||||
let
|
||||
modprobeVersion = "550.54.14";
|
||||
nvidia-modprobe = fetchFromGitHub {
|
||||
owner = "NVIDIA";
|
||||
repo = "nvidia-modprobe";
|
||||
rev = modprobeVersion;
|
||||
sha256 = "sha256-iBRMkvOXacs/llTtvc/ZC5i/q9gc8lMuUHxMbu8A+Kg=";
|
||||
};
|
||||
modprobePatch = substituteAll {
|
||||
src = ./modprobe.patch;
|
||||
inherit modprobeVersion;
|
||||
patchedModprobe = applyPatches {
|
||||
src = nvidia-modprobe.src.override {
|
||||
version = modprobeVersion;
|
||||
hash = "sha256-iBRMkvOXacs/llTtvc/ZC5i/q9gc8lMuUHxMbu8A+Kg=";
|
||||
};
|
||||
patches = [
|
||||
(replaceVars ./modprobe.patch {
|
||||
inherit modprobeVersion;
|
||||
})
|
||||
];
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "libnvidia-container";
|
||||
version = "1.16.2";
|
||||
version = "1.17.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "NVIDIA";
|
||||
repo = "libnvidia-container";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-hX+2B+0kHiAC2lyo6kwe7DctPLJWgRdbhlc316OO3r8=";
|
||||
hash = "sha256-JmJKvAOEPyjVx2Frd0tAMBjnAUTMpMh1KBt6wr5RRmk=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Locations of nvidia driver libraries are not resolved via ldconfig which
|
||||
# doesn't get used on NixOS.
|
||||
# TODO: The latter doesn't really apply anymore.
|
||||
# Additional support binaries like nvidia-smi
|
||||
# are not resolved via the environment PATH but via the derivation output
|
||||
# path.
|
||||
(replaceVars ./fix-library-resolving.patch {
|
||||
(replaceVars ./0001-ldcache-don-t-use-ldcache.patch {
|
||||
inherit (addDriverRunpath) driverLink;
|
||||
})
|
||||
|
||||
# Use both PATH and the legacy nvidia-docker paths (NixOS artifacts)
|
||||
# for binary lookups.
|
||||
# TODO: Remove the legacy compatibility once nvidia-docker is removed
|
||||
# from NixOS.
|
||||
./0002-nvc-nvidia-docker-compatible-binary-lookups.patch
|
||||
|
||||
# fix bogus struct declaration
|
||||
./inline-c-struct.patch
|
||||
./0003-nvc-fix-struct-declaration.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
@@ -66,11 +70,10 @@ stdenv.mkDerivation rec {
|
||||
versions.mk
|
||||
|
||||
mkdir -p deps/src/nvidia-modprobe-${modprobeVersion}
|
||||
cp -r ${nvidia-modprobe}/* deps/src/nvidia-modprobe-${modprobeVersion}
|
||||
cp -r ${patchedModprobe}/* deps/src/nvidia-modprobe-${modprobeVersion}
|
||||
chmod -R u+w deps/src
|
||||
pushd deps/src
|
||||
|
||||
patch -p0 < ${modprobePatch}
|
||||
touch nvidia-modprobe-${modprobeVersion}/.download_stamp
|
||||
popd
|
||||
|
||||
@@ -146,6 +149,9 @@ stdenv.mkDerivation rec {
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.linux;
|
||||
mainProgram = "nvidia-container-cli";
|
||||
maintainers = with maintainers; [ cpcloud ];
|
||||
maintainers = with maintainers; [
|
||||
cpcloud
|
||||
msanft
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
gnum4,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "nvidia-modprobe";
|
||||
version = "550.54.14";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "NVIDIA";
|
||||
repo = "nvidia-modprobe";
|
||||
rev = version;
|
||||
hash = "sha256-iBRMkvOXacs/llTtvc/ZC5i/q9gc8lMuUHxMbu8A+Kg=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ gnum4 ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace utils.mk --replace-fail "/usr/local" "$out"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Load the NVIDIA kernel module and create NVIDIA character device files ";
|
||||
homepage = "https://github.com/NVIDIA/nvidia-modprobe";
|
||||
license = lib.licenses.gpl2;
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user