Skip to content

Commit a2eec9e

Browse files
author
Ignacio Quintero
committed
support nvidia-docker2 natively in local mode.
Local Mode wit GPU relied on the environment having the nvidia runtime as default. This changes that so that runtime: nvidia is passed in docker-compose.yaml allowing local mode to work with a vanilla nvidia-docker2 installation.
1 parent c8006fa commit a2eec9e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66
=========
77

88
* feature: Local Mode: Add support for Batch Inference
9+
* enhancement: Local Mode: support nvidia-docker2 natively
910

1011
1.11.2
1112
======

src/sagemaker/local/image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ def _generate_compose_file(self, command, additional_volumes=None, additional_en
362362
}
363363

364364
content = {
365-
# Some legacy hosts only support the 2.1 format.
366-
'version': '2.1',
365+
# Use version 2.3 as a minimum so that we can specify the runtime
366+
'version': '2.3',
367367
'services': services,
368368
'networks': {
369369
'sagemaker-local': {'name': 'sagemaker-local'}
@@ -415,6 +415,11 @@ def _create_docker_host(self, host, environment, optml_subdirs, command, volumes
415415
}
416416
}
417417

418+
# for GPU support pass in nvidia as the runtime, this is equivalent
419+
# to setting --runtime=nvidia in the docker commandline.
420+
if self.instance_type == 'local_gpu':
421+
host_config['runtime'] = 'nvidia'
422+
418423
if command == 'serve':
419424
serving_port = sagemaker.utils.get_config_value('local.serving_port',
420425
self.sagemaker_session.config) or 8080

0 commit comments

Comments
 (0)