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

feat(initialize): default to first GPU when gpu_id not provided #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

btruhand
Copy link

@btruhand btruhand commented May 31, 2024

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 ID

Screenshot 2024-05-31 at 4 09 14 PM

Checking 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 raised

Screenshot 2024-05-31 at 4 20 49 PM

Considering that the existing call already uses .get instead of indexing operator, arguably there was already awareness that gpu_id may be missing, but it was not properly handled. Or it was thought that in subsequent initialization attempts the problem will be fixed

Description 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 use

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines +66 to +69
@require_torch
@pytest.mark.skipif(not _is_gpu_available(), reason="No GPU available")
@slow
def test_initialize_without_gpu_id_fallback_to_first_gpu(inference_handler):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never got to test this myself since I don't have GPU access currently. Also not sure if we want to use the skipif on availability of GPU. I didn't see any such marks in the test file. But i think it makes sense to have it

@kurtgdl
Copy link

kurtgdl commented Dec 31, 2024

I'm also being faced with this error with the release 2.3.0.

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

Successfully merging this pull request may close these issues.

2 participants