How to use get_gpu_count method in lisa

Best Python code snippet using lisa_python

test.py

Source:test.py Github

copy

Full Screen

...34 if cfg.TEST.WORKERS > 0:35 torch.multiprocessing.set_start_method("spawn", force=True)36 _, weights, _, _, _ = load_checkpoint(checkpoint, device)37 model = get_model(cfg, device)38 if get_gpu_count(cfg, mode="train") > 1 and get_gpu_count(cfg, mode="test") == 1:39 weights = rename_ordered_dict_from_parallel(weights)40 if get_gpu_count(cfg, mode="train") == 1 and get_gpu_count(cfg, mode="test") > 1:41 weights = rename_ordered_dict_to_parallel(weights)42 model.load_state_dict(weights)43 criterion = get_loss(cfg)44 dataloader = get_dataloader(cfg, "test")45 mask_config = load_yaml(cfg.DATASET.MASK.CONFIG)46 metrics = model_validation(model, criterion, dataloader, return_ave=False)47 print(f"Loss on test set: {metrics['val_loss']}")48 labels = [mask_config["class2label"][i] for i in sorted(mask_config["class2label"])]49 metrics_df = pd.DataFrame(50 {51 "recall": metrics["recall"],52 "precision": metrics["precision"],53 "f1": metrics["f1"],54 },...

Full Screen

Full Screen

test_initialize_paddle_driver.py

Source:test_initialize_paddle_driver.py Github

copy

Full Screen

...46 assert isinstance(driver, PaddleFleetDriver)47@pytest.mark.paddle48@pytest.mark.parametrize(49 "device", 50 [-2, [0, get_gpu_count() + 1, 3], [-2], get_gpu_count() + 1]51)52@magic_argv_env_context53def test_device_out_of_range(device):54 """55 测试传入的device超过范围的情况56 """57 model = PaddleNormalModel_Classification_1(20, 10)58 with pytest.raises(ValueError):...

Full Screen

Full Screen

conftest.py

Source:conftest.py Github

copy

Full Screen

...3def require_gpu():4 import os5 from pyspec.machine.util.gpu import get_gpu_count6 # tests should always run on the last GPU!7 if get_gpu_count() > 1:8 print("configure tests to run on last GPU, since several are available: {}".format(get_gpu_count()))9 os.environ['CUDA_VISIBLE_DEVICES'] = "{}".format(get_gpu_count() - 1)10 else:...

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 lisa 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