首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >多gpu推理tensorflow

多gpu推理tensorflow
EN

Stack Overflow用户
提问于 2019-07-10 23:37:50
回答 1查看 650关注 0票数 0

我想使用tensorflow/Keras执行多gpu推理

这是我的预测

代码语言:javascript
运行
复制
 model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)

 # Load weights trained on MS-COCO
 model.load_weights(COCO_MODEL_PATH, by_name=True)

 # COCO Class names
 # Index of the class in the list is its ID. For example, to get ID of
 # the teddy bear class, use: class_names.index('teddy bear')
 class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
                'bus', 'train', 'truck', 'boat', 'traffic light',
                'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
                'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
                'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
                'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
                'kite', 'baseball bat', 'baseball glove', 'skateboard',
                'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
                'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
                'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
                'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
                'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
                'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
                'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
                'teddy bear', 'hair drier', 'toothbrush']


 # Load a random image from the images folder
 file_names = next(os.walk(IMAGE_DIR))[2]
 image = skimage.io.imread(os.path.join(IMAGE_DIR, random.choice(file_names)))

 # Run detection
 results = model.detect([image], verbose=1)

 # Visualize results
 r = results[0]

有没有办法在多个gpus上运行这个模型?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-11 00:40:35

根据系统中的GPU数量增加GPU_COUNT,并在使用modellib.MaskRCNN创建模型时传递新的config

代码语言:javascript
运行
复制
class InferenceConfig(coco.CocoConfig):
    GPU_COUNT = 1 # increase the GPU count based on number of GPUs
    IMAGES_PER_GPU = 1

config = InferenceConfig()
model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)

https://github.com/matterport/Mask_RCNN/blob/master/samples/demo.ipynb

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56974191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档