當前位置: 首頁>>代碼示例>>Python>>正文


Python workspace.GetCUDAVersion方法代碼示例

本文整理匯總了Python中caffe2.python.workspace.GetCUDAVersion方法的典型用法代碼示例。如果您正苦於以下問題:Python workspace.GetCUDAVersion方法的具體用法?Python workspace.GetCUDAVersion怎麽用?Python workspace.GetCUDAVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在caffe2.python.workspace的用法示例。


在下文中一共展示了workspace.GetCUDAVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_nvidia_info

# 需要導入模塊: from caffe2.python import workspace [as 別名]
# 或者: from caffe2.python.workspace import GetCUDAVersion [as 別名]
def get_nvidia_info():
    return (
        get_nvidia_smi_output(),
        workspace.GetCUDAVersion(),
        workspace.GetCuDNNVersion(),
    ) 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:8,代碼來源:c2.py

示例2: main

# 需要導入模塊: from caffe2.python import workspace [as 別名]
# 或者: from caffe2.python.workspace import GetCUDAVersion [as 別名]
def main():
    args = parse_args()

    if args.dtype == 'float32':
        args.dtype = 'float'

    # report some available info
    if args.device == 'gpu':
        assert args.num_gpus > 0, "Number of GPUs must be specified in GPU mode"
        print("__caffe2.cuda_version__=%s" % (json.dumps(workspace.GetCUDAVersion())))
        print("__caffe2.cudnn_version__=%s" % (json.dumps(workspace.GetCuDNNVersion())))

    try:
        opts = vars(args)
        opts['phase'] = 'inference' if args.forward_only else 'training'
        model_title, times = benchmark(opts)
    except Exception as err:
        #TODO: this is not happenning, program terminates earlier.
        # For now, do not rely on __results.status__=...
        times = np.zeros(0)
        model_title = 'Unk'
        print ("Critical error while running benchmarks (%s). See stacktrace below." % (str(err)))
        traceback.print_exc(file=sys.stdout)

    if len(times) > 0:
        mean_time = np.mean(times) # seconds
        # Compute mean throughput
        num_local_devices = 1 if args.device == 'cpu' else args.num_gpus  #Number of compute devices per node
        num_devices = num_local_devices * args.num_workers                #Global number of devices
        replica_batch = args.batch_size                                   #Input is a replica batch
        mean_throughput = num_devices * replica_batch / mean_time         #images / sec
        #
        print("__results.time__=%s" % (json.dumps(1000.0 * mean_time)))
        print("__results.throughput__=%s" % (json.dumps(int(mean_throughput))))
        print("__exp.model_title__=%s" % (json.dumps(model_title)))
        print("__results.time_data__=%s" % (json.dumps((1000.0*times).tolist())))
    else:
        print("__results.status__=%s" % (json.dumps("failure"))) 
開發者ID:HewlettPackard,項目名稱:dlcookbook-dlbs,代碼行數:40,代碼來源:benchmarks.py


注:本文中的caffe2.python.workspace.GetCUDAVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。