Skip to content

Commit cba4c20

Browse files
teticioJoseJuan98
authored andcommitted
fix: Add gpu capability to local (aws#3136)
1 parent 20ae406 commit cba4c20

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/sagemaker/local/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,9 @@ def _create_docker_host(self, host, environment, optml_subdirs, command, volumes
759759
# for GPU support pass in nvidia as the runtime, this is equivalent
760760
# to setting --runtime=nvidia in the docker commandline.
761761
if self.instance_type == "local_gpu":
762-
host_config["runtime"] = "nvidia"
762+
host_config["deploy"] = {
763+
"resources": {"reservations": {"devices": [{"capabilities": ["gpu"]}]}}
764+
}
763765

764766
if command == "serve":
765767
serving_port = (

tests/unit/test_image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,10 @@ def test_container_has_gpu_support(tmpdir, sagemaker_session):
574574
)
575575

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

580582

581583
def test_container_does_not_enable_nvidia_docker_for_cpu_containers(sagemaker_session):

0 commit comments

Comments
 (0)