Skip to content

Add GPU support for containers - #122

Closed
sclaw wants to merge 1 commit into
mainfrom
feature/gpu-support
Closed

Add GPU support for containers#122
sclaw wants to merge 1 commit into
mainfrom
feature/gpu-support

Conversation

@sclaw

@sclaw sclaw commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a config field to allocate a GPU alongside other resources (CPU and memory). When the GPU field is greater than 1, docker processes will execute with the gpus=# flag.

(warning: this code was update by AI)

@sclaw

sclaw commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

This code has been tested by running LISFLOOD-FP on a GPU-enabled container via SEPEX. The model ran with no issues.

@ar-siddiqui ar-siddiqui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this needs a lot of thinking, because it is a rule modification that we are making, we are saying that we will limit containers by the resources in their registration YAML.

Before this we were not setting CPU and Mem limitation at Container launch. These resources were just used for job queue to approximate how many jobs to run. This is something I decided based on how Docker CPU and Mem limitation work, which is not straight forward. So for example if I set --cpus=2, it only means that if the container tried to use more than these CPUs, Docker will kill the container. We do not want this behavior. It does not mean Docker will wait to reserve these resources. There is no guaranteed reservation with Docker.

Also we need to integrate GPU resources in configuration.

I think at most what we can safely do is pass GPU flag to Docker if a process requires GPU.

I recommend that we park this issue as feature request and discuss all the consequences there and/or for now do a feature enhancement to just pass GPU flag to docker to use GPU when it is requested by process and available on host machine.

Comment thread api/controllers/docker.go
Resources: container.Resources(resources),
}

// Set device requests (for GPUs) from resources

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would this set just GPU or CPU as well?

if maxMemory > 0 && p.Config.Resources.Memory > maxMemory {
return fmt.Errorf("process requires %dMB memory but max allowed is %dMB", p.Config.Resources.Memory, maxMemory)
}
if p.Config.Resources.GPUs < 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What if requested GPUs are higher than machine requested.

@ar-siddiqui

Copy link
Copy Markdown
Collaborator

Closing it in favor of a comprehensive planned work.
#132

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants