You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from mmdeploy_runtime import Classifier
import cv2
import numpy as np
from cuda import cudart
img = cv2.imread('/root/workspace/mmpretrain/demo/demo.JPEG')
model = []
for i in range(2):
model.append(Classifier('/root/workspace/mmdeploy/work-dir/ort', 'cuda', i))
while True:
for i in range(2):
cudart.cudaSetDevice(i)
res = model[i](img)
print(res)
from mmdeploy_runtime import Classifier
import cv2
import numpy as np
from cuda import cudart
img = cv2.imread('/root/workspace/mmpretrain/demo/demo.JPEG')
model = []
for i in range(2):
model.append(Classifier('/root/workspace/mmdeploy/work-dir/ort', 'cuda', i))
while True:
for i in range(2):
cudart.cudaSetDevice(i)
res = model[i](img)
print(res)
Checklist
Describe the bug
我想在一个python代码中,将模型同时加载到两个GPU上,循环让两个GPU进行推理,第一次可以推理成功,第二次就报错了
Reproduction
主要代码如下:
`gpu_count = len(gpus_id)
try:
for i in range(len(gpus_id)):
gpu_id = int(gpus_id[i])
print(gpu_id)
model_path = "'./resnet50{}'".format(i)
exec('classifier{} = Classifier(model_path= {} ,device_name= {}, device_id = {})'.format(
i, model_path, "'cuda'", gpu_id))
except RuntimeError as e:
classifier = Classifier(model_path='./resnet50', device_name='cpu', device_id=0)`
Environment
Error traceback
The text was updated successfully, but these errors were encountered: