Skip to content

Explicitly disable nvidia device injection for --gpus=0#48482

Merged
thaJeztah merged 1 commit intomoby:masterfrom
elezar:fix-gpus-0
Sep 12, 2024
Merged

Explicitly disable nvidia device injection for --gpus=0#48482
thaJeztah merged 1 commit intomoby:masterfrom
elezar:fix-gpus-0

Conversation

@elezar
Copy link
Contributor

@elezar elezar commented Sep 11, 2024

This change ensures that when --gpus=0 is selected, the injection of NVIDIA device nodes and libraries is disabled by setting the NVIDIA_VISIBLE_DEVICES environment variable to void instead of leaving this unspecfied.

- What I did

Updated the handling of the --gpus=0 flag to ensure that the NVIDIA_VISBLE_DEVICES envvar in the container is set to void instead of being left unspecified.

- How I did it

Added a conditional check for Count == 0 when the NVIDIA_VISBLE_DEVICES envvar is being constructed.

- How to verify it

Running:

docker run --rm -ti --runtime=nvidia --gpus=0 ubuntu bash -c "ls /dev/nvidia*"

and

docker run --rm -ti --runtime=nvidia --gpus=0 ubuntu bash -c "ldconfig -p | grep libcuda.so"

should show no devices or libraries on a system with NVIDIA GPUs.

- Description for the changelog

* Updated the handling of the `--gpus=0` flag to be consistent with the NVIDIA Container Runtime.

- A picture of a cute animal (not mandatory but encouraged)

This change ensures that when --gpus=0 is selected, the injection of
NVIDIA device nodes and libraries is disabled by setting the
NVIDIA_VISIBLE_DEVICES environment variable to void instead of
leaving this unspecfied.

Signed-off-by: Evan Lezar <[email protected]>
@elezar
Copy link
Contributor Author

elezar commented Sep 11, 2024

/cc @klueska @cdesiniotis

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants