microsoft / microsoft/vscode-remote-release
GPU detection: Not only check for runtime, but also number of GPUs
@chrmarti is already working on this.
Since Sep 24, 2024.
- Dominant language
- Dockerfile
- Stars
- 4.2k
- Forks
- 469
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
@chrmarti
DevContainers v0.386.0 (pre-release)
Hello,
It seems that this feature is still broken (v0.386.0). If I create a remote machine (GCP) with GPU and fully installed nvidia-stack, I can build and run the devcontainer using
"hostRequirements": { "gpu": "optional" },But if I remove the GPU from my remote machine I can't start the docker container anymore as it claims having detected a GPU despite the fact that no GPU is attached:
Output of devcontainer console is:
[21551 ms] Start: Run: docker info -f {{.Runtimes.nvidia}}
[21755 ms] GPU support found, add GPU flags to docker call.
...
If I run the command you have used in your ts-scripts on the machine (no GPU anymore) I get:
{nvidia-container-runtime [] }
I think you are just checking whether the nvidia-container-runtime is available but not whether an actual gpu is attached.
const runtimeFound = result.stdout.includes('nvidia-container-runtime');
So,
`export async function extraRunArgs(common: ResolverParameters, params: DockerResolverParameters, config: DevContainerFromDockerfileConfig | DevContainerFromImageConfig) {
const extraArguments: string[] = [];
if (config.hostRequirements?.gpu) {
if (await checkDockerSupportForGPU(params)) { common.output.write(`GPU support found, add GPU flags to docker call.`); extraArguments.push('--gpus', 'all'); } else { if (config.hostRequirements?.gpu !== 'optional') { common.output.write('No GPU support found yet a GPU was required - consider marking it as "optional"', LogLevel.Warning); } }}
return extraArguments;
}`
Will add --gpus 'all' if the runtime is available even if no gpu is attached. Unfortunately the container won't start if --gpus all is given but no GPU is attached to the computer. Am I missing something here?
Originally posted by @maro-otto in #9385
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.