Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run a docker container with GPU support? #927

Closed
alex-litvak opened this issue Jul 21, 2022 · 1 comment
Closed

How to run a docker container with GPU support? #927

alex-litvak opened this issue Jul 21, 2022 · 1 comment
Labels

Comments

@alex-litvak
Copy link

We're using CreateContainer function to run a docker container. I need to pass the --gpu argument in order to enable GPU support:
docker run --gpus all ...

How can I pass the --gpus option programmatically? Thanks in advance!

@fsouza
Copy link
Owner

fsouza commented Aug 18, 2022

Hmm to be honest I'm not totally sure. I think gpus are represented as device requests in the Docker API? Meaning you'd need to set DeviceRequests in your HostConfig. Something like (untested):

hostConfig := HostConfig{
    // other attributes
    DeviceRequests: []DeviceRequest{
        {
            Count: 1,
            Capabilities: [][]string{{"gpu"}},
         },
    },
    // other attributes
}
// use hostConfig to create/start the container

(you can also set Count to -1 to make all gpus available)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants