我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用fast_rcnn.config.cfg.GPU_ID。
def nms(dets, thresh, force_cpu=False): """Dispatch to either CPU or GPU NMS implementations.""" if dets.shape[0] == 0: return [] if cfg.USE_GPU_NMS and not force_cpu: return gpu_nms(dets, thresh, device_id=cfg.GPU_ID) else: return cpu_nms(dets, thresh)
def _init_caffe(cfg): """Initialize pycaffe in a training process. """ import caffe # fix the random seeds (numpy and caffe) for reproducibility np.random.seed(cfg.RNG_SEED) caffe.set_random_seed(cfg.RNG_SEED) # set up caffe caffe.set_mode_gpu() caffe.set_device(cfg.GPU_ID)
def nms(dets, thresh): """Dispatch to either CPU or GPU NMS implementations.""" if dets.shape[0] == 0: return [] if cfg.USE_GPU_NMS: return gpu_nms(dets, thresh, device_id=cfg.GPU_ID) else: return cpu_nms(dets, thresh)
def rpn_generate_single_gpu(prototxt, caffemodel, imdb, rank, gpus, output_dir): cfg.GPU_ID = gpus[rank] caffe.set_mode_gpu() caffe.set_device(cfg.GPU_ID) net = caffe.Net(prototxt, caffemodel, caffe.TEST) imdb_boxes = imdb_proposals(net, imdb, rank, len(gpus), output_dir)
def nms(dets, thresh, force_cpu=False): """Dispatch to either CPU or GPU NMS implementations.""" if dets.shape[0] == 0: return [] if cfg.USE_GPU_NMS and not force_cpu: from nms.gpu_nms import gpu_nms return gpu_nms(dets, thresh, device_id=cfg.GPU_ID) else: from nms.cpu_nms import cpu_nms return cpu_nms(dets, thresh)
def gpu_conf(cfg, gpu_id=None): if gpu_id==None: DEVICE_ID_LIST = GPUtil.getFirstAvailable() if (len(DEVICE_ID_LIST) > 0): cfg.GPU_ID = DEVICE_ID_LIST[0] # grab first element from list else: cfg.GPU_ID=gpu_id return cfg
def build_net(): prototxt = os.path.join(cfg.ROOT_DIR, 'models', NETS[args.demo_net][0], 'faster_rcnn_alt_opt', 'faster_rcnn_test.pt') caffemodel = os.path.join(cfg.ROOT_DIR, 'data', 'faster_rcnn_models', NETS[args.demo_net][1]) caffe.set_mode_gpu() caffe.set_device(args.gpu_id) cfg.GPU_ID = args.gpu_id net = caffe.Net(prototxt, caffemodel, caffe.TEST) return net