Skip to content

fix: Add gpu capability to local #3136

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

Merged
merged 5 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sagemaker/local/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,9 @@ def _create_docker_host(self, host, environment, optml_subdirs, command, volumes
# for GPU support pass in nvidia as the runtime, this is equivalent
# to setting --runtime=nvidia in the docker commandline.
if self.instance_type == "local_gpu":
host_config["runtime"] = "nvidia"
host_config["deploy"] = {
"resources": {"reservations": {"devices": [{"capabilities": ["gpu"]}]}}
}

if command == "serve":
serving_port = (
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ def test_container_has_gpu_support(tmpdir, sagemaker_session):
)

docker_host = sagemaker_container._create_docker_host("host-1", {}, set(), "train", [])
assert "runtime" in docker_host
assert docker_host["runtime"] == "nvidia"
assert "deploy" in docker_host
assert docker_host["deploy"] == {
"resources": {"reservations": {"devices": [{"capabilities": ["gpu"]}]}}
}


def test_container_does_not_enable_nvidia_docker_for_cpu_containers(sagemaker_session):
Expand Down