How to use clear_dmesg method in avocado

Best Python code snippet using avocado_python

run

Source:run Github

copy

Full Screen

...64 print("Clearing page cache ...")65 subprocess.check_call([66 os.path.join(CWD, '../../../scripts/drop-caches'),67 ])68def clear_dmesg():69 print("Clearing dmesg ...")70 subprocess.check_call([71 'dmesg',72 '-C',73 ])74def sync_fs():75 print("Sync ...")76 subprocess.check_call([77 'sync',78 ])79 clear_cache()80def dump_dmesg(args):81 print("Dumping dmesg ...")82 subprocess.call(83 ['dmesg', '-t',],84 stdout = args.log,85 stderr = args.log,86 )87def run_c3d_original(args, caffe_bin):88 load_original_driver()89 data_folder = os.path.abspath(args.dfolder)90 prototxt_root_folder = os.path.join(CWD, '..', 'examples', 'c3d_ucf101_training')91 template_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt.template')92 prototxt_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt')93 with open(os.path.join(args.rfolder, 'result-original.data'), 'w') as result_file:94 result_file.write('length,total_time (s)\n')95 with open(template_file_path, 'r') as f:96 template_content = f.read()97 template_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonFreadData')98 for length in (12, 24, 36, 48, 60, 72, 84,):99 print('Benchmarking C3D original with video length {} ...'.format(length))100 prototxt_content = template_content.replace('{{ LENGTH }}', str(length))101 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'c3d-train-data-{}.mem'.format(length)))102 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'c3d-train-label-{}.mem'.format(length)))103 with open(prototxt_file_path, 'w') as g:104 g.write(prototxt_content)105 clear_dmesg()106 clear_cache()107 start_timestamp = datetime.datetime.now()108 retcode = subprocess.call(109 [caffe_bin, 'train', '--solver=solver.prototxt',],110 cwd = prototxt_root_folder,111 stdout = args.log,112 stderr = args.log113 )114 end_timestamp = datetime.datetime.now()115 if retcode == 0:116 print('Success. Writing result ...')117 result_file.write('{},{}\n'.format(length, (end_timestamp - start_timestamp).total_seconds()))118 else:119 print('Fail. Maybe due to out-of-memory')120def run_c3d_uvm(args, caffe_bin):121 load_original_driver()122 data_folder = os.path.abspath(args.dfolder)123 prototxt_root_folder = os.path.join(CWD, '..', 'examples', 'c3d_ucf101_training')124 template_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt.template')125 prototxt_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt')126 with open(os.path.join(args.rfolder, 'result-uvm.data'), 'w') as result_file:127 result_file.write('length,total_time (s)\n')128 with open(template_file_path, 'r') as f:129 template_content = f.read()130 template_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonFreadData')131 for length in (12, 24, 36, 48, 60, 72, 84,):132 print('Benchmarking C3D UVM with video length {} ...'.format(length))133 prototxt_content = template_content.replace('{{ LENGTH }}', str(length))134 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'c3d-train-data-{}.mem'.format(length)))135 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'c3d-train-label-{}.mem'.format(length)))136 with open(prototxt_file_path, 'w') as g:137 g.write(prototxt_content)138 clear_dmesg()139 clear_cache()140 start_timestamp = datetime.datetime.now()141 retcode = subprocess.call(142 [caffe_bin, 'train', '--solver=solver.prototxt', '--enable_uvm=true',],143 cwd = prototxt_root_folder,144 stdout = args.log,145 stderr = args.log146 )147 end_timestamp = datetime.datetime.now()148 if retcode == 0:149 print('Success. Writing result ...')150 result_file.write('{},{}\n'.format(length, (end_timestamp - start_timestamp).total_seconds()))151 else:152 print('Fail. Maybe due to out-of-memory')153def run_c3d_nvmgpu(args, caffe_bin):154 load_nvmgpu_driver()155 data_folder = os.path.abspath(args.dfolder)156 data_tmp_folder = os.path.join(data_folder, 'tmp')157 if not os.path.exists(data_tmp_folder):158 os.mkdir(data_tmp_folder)159 prototxt_root_folder = os.path.join(CWD, '..', 'examples', 'c3d_ucf101_training')160 template_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt.template')161 prototxt_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt')162 with open(os.path.join(args.rfolder, 'result-dragon.data'), 'w') as result_file:163 result_file.write('length,total_time (s)\n')164 with open(template_file_path, 'r') as f:165 template_content = f.read()166 template_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonData')167 for length in (12, 24, 36, 48, 60, 72, 84,):168 print('Benchmarking C3D DRAGON with video length {} ...'.format(length))169 prototxt_content = template_content.replace('{{ LENGTH }}', str(length))170 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'c3d-train-data-{}.mem'.format(length)))171 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'c3d-train-label-{}.mem'.format(length)))172 with open(prototxt_file_path, 'w') as g:173 g.write(prototxt_content)174 clear_dmesg()175 clear_cache()176 start_timestamp = datetime.datetime.now()177 retcode = subprocess.call(178 [caffe_bin, 'train', '--solver=solver.prototxt', '--enable_dragon=true', '--dragon_tmp_folder={}'.format(data_tmp_folder)],179 cwd = prototxt_root_folder,180 stdout = args.log,181 stderr = args.log182 )183 end_timestamp = datetime.datetime.now()184 dump_dmesg(args)185 if retcode == 0:186 print('Success. Writing result ...')187 result_file.write('{},{}\n'.format(length, (end_timestamp - start_timestamp).total_seconds()))188 else:189 raise Exception('Fail. This should never happen!!!')190def run_c3d_cpu(args, caffe_bin):191 load_original_driver()192 data_folder = os.path.abspath(args.dfolder)193 data_tmp_folder = os.path.join(data_folder, 'tmp')194 if not os.path.exists(data_tmp_folder):195 os.mkdir(data_tmp_folder)196 prototxt_root_folder = os.path.join(CWD, '..', 'examples', 'c3d_ucf101_training')197 template_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt.template')198 prototxt_file_path = os.path.join(prototxt_root_folder, 'train_simple.prototxt')199 with open(os.path.join(args.rfolder, 'result-cpu.data'), 'w') as result_file:200 result_file.write('length,total_time (s)\n')201 with open(template_file_path, 'r') as f:202 template_content = f.read()203 template_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonMmapData')204 for length in (12, 24, 36, 48, 60, 72, 84,):205 print('Benchmarking C3D CPU with video length {} ...'.format(length))206 prototxt_content = template_content.replace('{{ LENGTH }}', str(length))207 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'c3d-train-data-{}.mem'.format(length)))208 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'c3d-train-label-{}.mem'.format(length)))209 with open(prototxt_file_path, 'w') as g:210 g.write(prototxt_content)211 clear_dmesg()212 clear_cache()213 start_timestamp = datetime.datetime.now()214 retcode = subprocess.call(215 [caffe_bin, 'train', '--solver=solver_cpu.prototxt', '--enable_mmap=true', '--dragon_tmp_folder={}'.format(data_tmp_folder)],216 cwd = prototxt_root_folder,217 stdout = args.log,218 stderr = args.log219 )220 end_timestamp = datetime.datetime.now()221 if retcode == 0:222 print('Success. Writing result ...')223 result_file.write('{},{}\n'.format(length, (end_timestamp - start_timestamp).total_seconds()))224 else:225 raise Exception('Fail. This should never happen!!!')226def run_resnet_original(args, caffe_bin):227 load_original_driver()228 data_folder = os.path.abspath(args.dfolder)229 pscript_root_folder = os.path.join(CWD, '..', 'examples', 'resnet-imagenet-caffe')230 with open(os.path.join(args.rfolder, 'result-original.data'), 'w') as result_file:231 result_file.write('model,total_time (s)\n')232 for num in (32, 50, 101, 152,):233 prototxt_root_folder = os.path.join(pscript_root_folder, 'resnet_{}'.format(num))234 template_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt.template'.format(num))235 prototxt_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt'.format(num))236 with open(template_file_path, 'r') as f:237 print('Benchmarking Resnet-{} original ...'.format(num))238 template_content = f.read()239 prototxt_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonFreadData')240 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'resnet-train-data-{}.mem'.format(length)))241 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'resnet-train-label-{}.mem'.format(length)))242 with open(prototxt_file_path, 'w') as g:243 g.write(prototxt_content)244 clear_dmesg()245 clear_cache()246 start_timestamp = datetime.datetime.now()247 retcode = subprocess.call(248 [caffe_bin, 'train', '--solver=resnet_{}/resnet_{}_solver.prototxt'.format(num, num),],249 cwd = pscript_root_folder,250 stdout = args.log,251 stderr = args.log252 )253 end_timestamp = datetime.datetime.now()254 if retcode == 0:255 print('Success. Writing result ...')256 result_file.write('resnet_{},{}\n'.format(num, (end_timestamp - start_timestamp).total_seconds()))257 else:258 print('Fail. Maybe due to out-of-memory')259def run_resnet_uvm(args, caffe_bin):260 load_original_driver()261 data_folder = os.path.abspath(args.dfolder)262 pscript_root_folder = os.path.join(CWD, '..', 'examples', 'resnet-imagenet-caffe')263 with open(os.path.join(args.rfolder, 'result-uvm.data'), 'w') as result_file:264 result_file.write('model,total_time (s)\n')265 for num in (32, 50, 101, 152,):266 prototxt_root_folder = os.path.join(pscript_root_folder, 'resnet_{}'.format(num))267 template_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt.template'.format(num))268 prototxt_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt'.format(num))269 with open(template_file_path, 'r') as f:270 print('Benchmarking Resnet-{} UVM ...'.format(num))271 template_content = f.read()272 prototxt_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonFreadData')273 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'resnet-train-data-{}.mem'.format(length)))274 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'resnet-train-label-{}.mem'.format(length)))275 with open(prototxt_file_path, 'w') as g:276 g.write(prototxt_content)277 clear_dmesg()278 clear_cache()279 start_timestamp = datetime.datetime.now()280 retcode = subprocess.call(281 [caffe_bin, 'train', '--solver=resnet_{}/resnet_{}_solver.prototxt'.format(num, num), '--enable_uvm=true',],282 cwd = pscript_root_folder,283 stdout = args.log,284 stderr = args.log285 )286 end_timestamp = datetime.datetime.now()287 if retcode == 0:288 print('Success. Writing result ...')289 result_file.write('resnet_{},{}\n'.format(num, (end_timestamp - start_timestamp).total_seconds()))290 else:291 print('Fail. Maybe due to out-of-memory')292def run_resnet_nvmgpu(args, caffe_bin):293 load_nvmgpu_driver()294 data_folder = os.path.abspath(args.dfolder)295 pscript_root_folder = os.path.join(CWD, '..', 'examples', 'resnet-imagenet-caffe')296 with open(os.path.join(args.rfolder, 'result-dragon.data'), 'w') as result_file:297 result_file.write('model,total_time (s)\n')298 for num in (32, 50, 101, 152,):299 prototxt_root_folder = os.path.join(pscript_root_folder, 'resnet_{}'.format(num))300 template_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt.template'.format(num))301 prototxt_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt'.format(num))302 with open(template_file_path, 'r') as f:303 print('Benchmarking Resnet-{} DRAGON ...'.format(num))304 template_content = f.read()305 prototxt_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonData')306 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'resnet-train-data-{}.mem'.format(length)))307 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'resnet-train-label-{}.mem'.format(length)))308 with open(prototxt_file_path, 'w') as g:309 g.write(prototxt_content)310 clear_dmesg()311 clear_cache()312 start_timestamp = datetime.datetime.now()313 retcode = subprocess.call(314 [caffe_bin, 'train', '--solver=resnet_{}/resnet_{}_solver.prototxt'.format(num, num), '--enable_dragon=true', '--dragon_tmp_folder={}'.format(data_tmp_folder),],315 cwd = pscript_root_folder,316 stdout = args.log,317 stderr = args.log318 )319 end_timestamp = datetime.datetime.now()320 dump_dmesg(args)321 if retcode == 0:322 print('Success. Writing result ...')323 result_file.write('resnet_{},{}\n'.format(num, (end_timestamp - start_timestamp).total_seconds()))324 else:325 raise Exception('Fail. This should never happen!!!')326def run_resnet_cpu(args, caffe_bin):327 load_original_driver()328 data_folder = os.path.abspath(args.dfolder)329 pscript_root_folder = os.path.join(CWD, '..', 'examples', 'resnet-imagenet-caffe')330 with open(os.path.join(args.rfolder, 'result-cpu.data'), 'w') as result_file:331 result_file.write('model,total_time (s)\n')332 for num in (32, 50, 101, 152,):333 prototxt_root_folder = os.path.join(pscript_root_folder, 'resnet_{}'.format(num))334 template_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt.template'.format(num))335 prototxt_file_path = os.path.join(prototxt_root_folder, 'resnet_{}.prototxt'.format(num))336 with open(template_file_path, 'r') as f:337 print('Benchmarking Resnet-{} CPU ...'.format(num))338 template_content = f.read()339 prototxt_content = template_content.replace('{{ INPUT_LAYER_TYPE }}', 'DragonMmapData')340 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_DATA }}', os.path.join(data_folder, 'resnet-train-data-{}.mem'.format(length)))341 prototxt_content = prototxt_content.replace('{{ INPUT_TRAIN_LABEL }}', os.path.join(data_folder, 'resnet-train-label-{}.mem'.format(length)))342 with open(prototxt_file_path, 'w') as g:343 g.write(prototxt_content)344 clear_dmesg()345 clear_cache()346 start_timestamp = datetime.datetime.now()347 retcode = subprocess.call(348 [caffe_bin, 'train', '--solver=resnet_{}/resnet_{}_solver_cpu.prototxt'.format(num, num), '--enable_mmap=true', '--dragon_tmp_folder={}'.format(data_tmp_folder),],349 cwd = pscript_root_folder,350 stdout = args.log,351 stderr = args.log352 )353 end_timestamp = datetime.datetime.now()354 if retcode == 0:355 print('Success. Writing result ...')356 result_file.write('resnet_{},{}\n'.format(num, (end_timestamp - start_timestamp).total_seconds()))357 else:358 raise Exception('Fail. This should never happen!!!')...

Full Screen

Full Screen

pm_sched_domain.py

Source:pm_sched_domain.py Github

copy

Full Screen

...20 parser.add_option("-t", "--smt_level", dest="smt_level", default=-1,21 help="Sched smt power saving value 0/1/2")22 (options, args) = parser.parse_args()23 try:24 clear_dmesg()25 count_num_cpu()26 map_cpuid_pkgid()27 if is_hyper_threaded() and int(options.smt_level) >= 0:28 set_sched_smt_power(options.smt_level)29 if int(options.mc_level) >= 0:30 set_sched_mc_power(options.mc_level)31 if int(options.smt_level) >= 0 or int(options.mc_level) >= 0:32 status = verify_sched_domain_dmesg(options.mc_level, options.smt_level)33 reset_schedmc()34 if is_hyper_threaded():35 reset_schedsmt()36 return(status)37 else:38 print "INFO: Invalid arguments given"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful