feat(initialize): default to first GPU when gpu_id not provided #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
I was trying to deploy Huggingface Transformers on Sagemaker with multi-modal-server (MMS)
preload_model = true
(about preloading). Unfortunately I hit a snag and the server was unable to preload the model due to missing GPU IDChecking the MMS code here, here, and here we can see that no GPU ID is provided on model preload. Worse, the
service
will be constructed with no GPU ID and thus on subsequent attempts to initialize on prediction in the handler, the same exception will again be raisedConsidering that the existing call already uses
.get
instead of indexing operator, arguably there was already awareness thatgpu_id
may be missing, but it was not properly handled. Or it was thought that in subsequent initialization attempts the problem will be fixedDescription of changes:
Provide a default GPU ID of 0, if no
gpu_id
is provided, indicating downstream code to use the first GPU. I feel like this solution is quite sensible considering that we already check whether GPU is available or not and thus, we should be safe to assume that there is at least 1 GPU with GPU ID 0. Though I'm not entirely well-versed in GPU ID schemes so maybe 0 isn't a universally applicable ID to useBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.