Fix torch import

This commit is contained in:
clearml 2024-12-16 18:51:58 +02:00
parent aff27c62b8
commit 9f51a9334f
2 changed files with 8 additions and 3 deletions

View File

@ -1,7 +1,6 @@
import json import json
import os import os
import gc import gc
import torch
from collections import deque from collections import deque
from pathlib import Path from pathlib import Path
from random import random from random import random
@ -19,6 +18,11 @@ from clearml.storage.util import hash_dict
from .preprocess_service import BasePreprocessRequest from .preprocess_service import BasePreprocessRequest
from .endpoints import ModelEndpoint, ModelMonitoring, CanaryEP, EndpointMetricLogging from .endpoints import ModelEndpoint, ModelMonitoring, CanaryEP, EndpointMetricLogging
try:
import torch
except ImportError:
torch = None
class ModelRequestProcessorException(Exception): class ModelRequestProcessorException(Exception):
def __init__(self, message): def __init__(self, message):
@ -922,7 +926,8 @@ class ModelRequestProcessor(object):
del self._engine_processor_lookup[k] del self._engine_processor_lookup[k]
self._engine_processor_lookup.pop(k, None) self._engine_processor_lookup.pop(k, None)
gc.collect() gc.collect()
torch.cuda.empty_cache() if torch:
torch.cuda.empty_cache()
cleanup = False cleanup = False
model_monitor_update = False model_monitor_update = False
except Exception as ex: except Exception as ex:

View File

@ -1 +1 @@
__version__ = '1.3.1' __version__ = '1.3.2'