本文整理汇总了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(),
)
示例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")))