Chage torch import to conditional import
This commit is contained in:
@@ -4,7 +4,6 @@ import mimetypes
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import asyncio
|
import asyncio
|
||||||
import torch
|
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -287,6 +286,8 @@ async def update_embedding_config(
|
|||||||
request.app.state.EMBEDDING_FUNCTION = None
|
request.app.state.EMBEDDING_FUNCTION = None
|
||||||
import gc
|
import gc
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
if DEVICE_TYPE == 'cuda':
|
||||||
|
import torch
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
try:
|
try:
|
||||||
@@ -820,6 +821,8 @@ async def update_rag_config(
|
|||||||
request.app.state.RERANKING_FUNCTION = None
|
request.app.state.RERANKING_FUNCTION = None
|
||||||
import gc
|
import gc
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
if DEVICE_TYPE == 'cuda':
|
||||||
|
import torch
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
request.app.state.config.RAG_RERANKING_ENGINE = (
|
request.app.state.config.RAG_RERANKING_ENGINE = (
|
||||||
|
|||||||
Reference in New Issue
Block a user