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

View File

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