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

BUG: Fix using extra gpus due to match in __init__ #1400

Merged
merged 4 commits into from
Apr 29, 2024
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
2 changes: 1 addition & 1 deletion xinference/client/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def setup_cluster():
logging_conf=TEST_FILE_LOGGING_CONF,
)
endpoint = f"http://localhost:{port}"
if not api_health_check(endpoint, max_attempts=3, sleep_interval=5):
if not api_health_check(endpoint, max_attempts=10, sleep_interval=5):
raise RuntimeError("Endpoint is not available after multiple attempts")

yield f"http://localhost:{port}", supervisor_address
Expand Down
2 changes: 1 addition & 1 deletion xinference/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def setup_with_file_logging():
logging_conf=TEST_FILE_LOGGING_CONF,
)
endpoint = f"http://localhost:{port}"
if not api_health_check(endpoint, max_attempts=3, sleep_interval=5):
if not api_health_check(endpoint, max_attempts=10, sleep_interval=5):
raise RuntimeError("Endpoint is not available after multiple attempts")

try:
Expand Down
2 changes: 1 addition & 1 deletion xinference/core/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setup_cluster():
logging_conf=TEST_FILE_LOGGING_CONF,
)
endpoint = f"http://localhost:{port}"
if not api_health_check(endpoint, max_attempts=3, sleep_interval=5):
if not api_health_check(endpoint, max_attempts=10, sleep_interval=5):
raise RuntimeError("Endpoint is not available after multiple attempts")

yield f"http://localhost:{port}", f"http://localhost:{metrics_port}/metrics", supervisor_address
Expand Down
9 changes: 0 additions & 9 deletions xinference/model/llm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import codecs
import gc
import json
import os

Expand Down Expand Up @@ -266,11 +265,3 @@ def _install():
# register model description
for ud_llm in get_user_defined_llm_families():
LLM_MODEL_DESCRIPTIONS.update(generate_llm_description(ud_llm))

# Have to empty_cache here to reset CUDA status.
# Because `generate_engine_config_by_model_family` above has already initialized CUDA,
# which leads to torch initialization error in subprocess.
from ...device_utils import empty_cache

gc.collect()
empty_cache()
22 changes: 19 additions & 3 deletions xinference/model/llm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,25 @@ def _is_linux():

@staticmethod
def _has_cuda_device():
from ...utils import cuda_count

return cuda_count() > 0
"""
Use pynvml to impl this interface.
DO NOT USE torch to impl this, which will lead to some unexpected errors.
"""
from pynvml import nvmlDeviceGetCount, nvmlInit, nvmlShutdown

device_count = 0
try:
nvmlInit()
device_count = nvmlDeviceGetCount()
except:
pass
finally:
try:
nvmlShutdown()
except:
pass

return device_count > 0

@staticmethod
def _get_cuda_count():
Expand Down
Loading