Commit Graph

9 Commits

Author SHA1 Message Date
Simon Deziel
af0ab1854c Replace last occurence of 'which' with 'command -v'
The later is builtin and POSIX compliant.

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2021-10-28 17:10:05 -04:00
Diederik de Haas
7a7671655a
Replace 'which' with 'command -v'
The 'which' command is deprecated on Debian Sid as it is not POSIX
compliant and it's behavior is therefor not consistent, so replace it
with 'command -v' which is POSIX compliant.
See https://stackoverflow.com/a/677212 for details.

Also replaced a use of backticks (`) as that is deprecated as well.
See https://github.com/koalaman/shellcheck/wiki/SC2006 for details.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
2021-10-28 17:27:08 +02:00
Lukas Pirl
16a312e118
suppress false-negative error in templates and nvidia hook
``/proc`` might be mounted with ``hidepid=2``.
This makes ``/proc/1/…`` appear absent for non-root users.
When using the templates or the nvidia hook as a non-root user
(e.g., when creating unprivileged containers) the error
"/proc/1/uid_map: No such file or directory" is printed.
Since the script works correctly despite the error, this error
message might be confusing for users.

Signed-off-by: Lukas Pirl <git@lukas-pirl.de>
2019-07-22 14:39:23 +02:00
Felix Abecassis
52e1d4cb49 hooks/nvidia: handle spaces in NVIDIA_REQUIRE variables
Previously, environment variables with a space where splitted.

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2019-04-16 13:59:37 -07:00
Felix Abecassis
d23c6cc996 Fix license of the nvidia hook
Fixes: #2494

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-07-28 18:06:58 -07:00
Felix Abecassis
89f1ef110e hooks: implement passthrough for latest features of libnvidia-container
The "display" driver capability will expose /dev/nvidia-modeset:
9398d41d9f

The "--ldcache" argument allows overriding the location of the DSO cache:
41656bf9ed

The "--root" argument allows nvidia-container-cli to execute in a different rootfs:
019fdc14e3

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-03-19 15:38:53 -07:00
Felix Abecassis
4a0a5e89e1 hooks: fix nvidia hook when running under the lxc-start AppArmor profile
For a reason that I don't understand, the profile transition needs to
be done on the current process. Changing the attributes for a
subsequent execve(2) (with /proc/self/attr/exec) will cause the kernel
to set AT_SECURE in the auxiliary vector and thus secure_getenv(3)
inside libnvidia-container will return NULL.

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-03-19 15:34:49 -07:00
Felix Abecassis
b87243830e hooks: change the semantic of NVIDIA_VISIBLE_DEVICES=""
With LXC, you can override the value of an environment variable to
null, but you can't unset an existing variable.

The NVIDIA hook was previously activated when NVIDIA_VISIBLE_DEVICES
was set to null. As a result, it was not possible to disable the hook
by overriding the environment variable in the configuration.

The hook can now be disabled by setting NVIDIA_VISIBLE_DEVICES to
null or to the new special value "void".

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-02-02 06:19:13 -08:00
Felix Abecassis
58e29e9bf1 hooks: add mount hook to configure access to NVIDIA GPUs
This hook requires the nvidia-container-cli tool provided by libnvidia-container:
https://github.com/nvidia/libnvidia-container

For containers that do not have CUDA_VERSION or NVIDIA_VISIBLE_DEVICES
set in the environment, the hook will be a no-op.

To enable in the configuration file:
lxc.hook.mount = /usr/local/share/lxc/hooks/nvidia

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-12-18 16:17:23 -08:00