How to use get_gpu method in Airtest

Best Python code snippet using Airtest

keepa_gpu.py

Source:keepa_gpu.py Github

copy

Full Screen

1import time2import requests3from data_gather.api_key import *4days = 665def get_gpu(manufacturer, product, ASIN_list):6 """7 :param manufacturer: manufacturer of gpu, as part of save path8 :param product: gpu product name9 :param ASIN_list: list of ASINs10 :return:11 """12 for ASIN in ASIN_list:13 print(f'Requesting information of manufacturer: {manufacturer}, product: {product}, ASIN: {ASIN}')14 url = f'https://api.keepa.com/product?key={keepa_access_key}&domain=1&asin={ASIN}&history=1&buybox=1&days={days}'15 req = requests.get(url)16 with open(f'gpu/{manufacturer}/{product}-{ASIN}.json', 'wb') as f:17 f.write(req.content)18 time.sleep(45)19# MSI20get_gpu('MSI', 'NVIDIA Geforce GTX 1050 Ti', ['B01MAZ357B', 'B01N683IAQ'])21get_gpu('MSI', 'NVIDIA Geforce GTX 1650', ['B086VR4VHX', 'B086VQPW2T', 'B08GL81369'])22get_gpu('MSI', 'NVIDIA Geforce GTX 1660', ['B07PBLDV3D', 'B07P9G4QK1'])23get_gpu('MSI', 'NVIDIA Geforce GTX 1660 Super', ['B07ZK69HDK', 'B07ZHDZ1K6'])24get_gpu('MSI', 'NVIDIA Geforce GTX 1660 Ti', ['B07N824KNV', 'B07N825Y1L'])25get_gpu('MSI', 'NVIDIA Geforce RTX 2060', ['B07MC23VS4', 'B07MQ36Z6L'])26get_gpu('MSI', 'NVIDIA Geforce RTX 2060 Super', ['B07YXQ19NC'])27get_gpu('MSI', 'NVIDIA Geforce RTX 2070', ['B07J4VJX6L', 'B081YJPKTM', 'B082P1BF7H', 'B07JCD8GQN'])28get_gpu('MSI', 'NVIDIA Geforce RTX 2070 Super', ['B0856BVRFL', 'B07J4VJX6L'])29get_gpu('MSI', 'NVIDIA Geforce RTX 2080', ['B07GHXQTGZ'])30get_gpu('MSI', 'NVIDIA Geforce RTX 2080 Super', ['B07Y8NP7X7', 'B07VDMGYGZ'])31get_gpu('MSI', 'NVIDIA Geforce RTX 2080 Ti', ['B07GJ3ZD69'])32get_gpu('MSI', 'NVIDIA Geforce RTX 3060', ['B08WPJ5P4R', 'B08WPRMVWB'])33get_gpu('MSI', 'NVIDIA Geforce RTX 3070', ['B0956WYQ1B', 'B08KWPDXJZ', 'B08KWN2LZG'])34get_gpu('MSI', 'NVIDIA Geforce RTX 3070 Ti', ['B096HJC18P', 'B096HQC9Y5'])35get_gpu('MSI', 'NVIDIA Geforce RTX 3080', ['B0932CTHP6'])36get_gpu('MSI', 'NVIDIA Geforce RTX 3080 Ti', ['B095VZ6F73'])37get_gpu('MSI', 'NVIDIA Geforce RTX 3090', ['B08HRBW6VB'])38get_gpu('MSI', 'AMD Radeon RX 580', ['B06XZQMMHJ', 'B06Y19NMP3'])39get_gpu('MSI', 'AMD Radeon RX 5500 XT', ['B082G34GSL', 'B082G2XDLL'])40get_gpu('MSI', 'AMD Radeon RX 5600 XT', ['B08CKDLN91', 'B0843VSJ7D', 'B083VPXN78'])41get_gpu('MSI', 'AMD Radeon RX 5700 XT', ['B07WNSP41M'])42get_gpu('MSI', 'AMD Radeon RX 6700 XT', ['B08Z72P3R9'])43get_gpu('MSI', 'AMD Radeon RX 6800', ['B08RHQC4KQ'])44get_gpu('MSI', 'AMD Radeon RX 6800 XT', ['B08RJ6YBH5'])45get_gpu('MSI', 'AMD Radeon RX 6900 XT', ['B08W2GPR62'])46# EVGA47get_gpu('EVGA', 'NVIDIA Geforce GTX 960', ['B00SL2TQ2C'])48get_gpu('EVGA', 'NVIDIA Geforce GTX 1050 ti', ['B01MEFABEL'])49get_gpu('EVGA', 'NVIDIA Geforce GTX 1060', ['B01KU2CIIY', 'B01N683IAQ'])50get_gpu('EVGA', 'NVIDIA Geforce GTX 1650', ['B085WV18XN', 'B08CPL5BB1'])51get_gpu('EVGA', 'NVIDIA Geforce GTX 1660', ['B07RJGL33C'])52get_gpu('EVGA', 'NVIDIA Geforce GTX 1660 Super', ['B07ZHZL2JB'])53get_gpu('EVGA', 'NVIDIA Geforce GTX 1660 Ti', ['B07NBHXKK6'])54get_gpu('EVGA', 'NVIDIA Geforce RTX 2060', ['B083GH7LXW', 'B07P11QHZG'])55get_gpu('EVGA', 'NVIDIA Geforce RTX 2060 Super', ['B07VM9Q9R8', 'B07TLPWBJ4'])56get_gpu('EVGA', 'NVIDIA Geforce RTX 2070', ['B07J63W42X'])57get_gpu('EVGA', 'NVIDIA Geforce RTX 2070 Super', ['B07YMPZCPT'])58get_gpu('EVGA', 'NVIDIA Geforce RTX 2080', ['B07GHVK4KN', 'B07GHVWMBS'])59get_gpu('EVGA', 'NVIDIA Geforce RTX 2080 Super', ['B07VJPNG1M', 'B07VCH31N9'])60get_gpu('EVGA', 'NVIDIA Geforce RTX 2080 Ti', ['B07KSPW8HQ', 'B07KVKRLG2', 'B07GHW9VJZ'])61get_gpu('EVGA', 'NVIDIA Geforce RTX 3060', ['B08WM28PVH'])62get_gpu('EVGA', 'NVIDIA Geforce RTX 3070 Ti', ['B096WM6JFS'])63get_gpu('EVGA', 'NVIDIA Geforce RTX 3080 Ti', ['B09622N253'])64get_gpu('EVGA', 'NVIDIA Geforce RTX 3090', ['B08J61SS5R', 'B08J5F3G18'])65# ASUS66get_gpu('ASUS', 'NVIDIA Geforce GTX 1050 Ti', ['B01M360WG6', 'B01MG9AKKZ', 'B079JSKCW3'])67get_gpu('ASUS', 'NVIDIA Geforce GTX 1650 Super', ['B081L1JHGT', 'B081KY5L57'])68get_gpu('ASUS', 'NVIDIA Geforce GTX 1660', ['B07PFM57FL'])69get_gpu('ASUS', 'NVIDIA Geforce GTX 1660 Super', ['B07ZHWQ81N', 'B07ZGXG8GM', 'B081SPGMBD'])70get_gpu('ASUS', 'NVIDIA Geforce RTX 2060', ['B07R18TH1X', 'B07MSK1H93'])71get_gpu('ASUS', 'NVIDIA Geforce RTX 2060 Super', ['B085CP6W5Y'])72get_gpu('ASUS', 'NVIDIA Geforce RTX 2070', ['B07JFYT2KD'])73get_gpu('ASUS', 'NVIDIA Geforce RTX 2070 Super', ['B07TXRW3HX', 'B07TYWQ1SW'])74get_gpu('ASUS', 'NVIDIA Geforce RTX 2080', ['B07GKD7DND', 'B083R2SCRL'])75get_gpu('ASUS', 'NVIDIA Geforce RTX 2080 Super', ['B07VFKM4VQ'])76get_gpu('ASUS', 'NVIDIA Geforce RTX 2080 Ti', ['B07HY6QWXN'])77get_gpu('ASUS', 'NVIDIA Geforce RTX 3060', ['B08WHJPBFX', 'B08WGTL4CW'])78get_gpu('ASUS', 'NVIDIA Geforce RTX 3070', ['B08L8LG4M3', 'B08MT6B58K'])79get_gpu('ASUS', 'NVIDIA Geforce RTX 3070 Ti', ['B096YQ6WVW'])80get_gpu('ASUS', 'NVIDIA Geforce RTX 3080', ['B08J6F174Z', 'B08HH5WF97'])81get_gpu('ASUS', 'NVIDIA Geforce RTX 3090', ['B08J6GMWCQ', 'B08HJGNJ81'])82get_gpu('ASUS', 'AMD Radeon RX 570', ['B06Y5WGXX3'])83get_gpu('ASUS', 'AMD Radeon RX 580', ['B071L1VGQW', 'B071D8YQJD'])84get_gpu('ASUS', 'AMD Radeon RX 5500 XT', ['B083FM3XPJ', 'B082G4J2WG'])85get_gpu('ASUS', 'AMD Radeon RX 5600 XT', ['B083WFK6M4'])86get_gpu('ASUS', 'AMD Radeon RX 5700 XT', ['B07XC5CQDK'])87get_gpu('ASUS', 'AMD Radeon RX 6700 XT', ['B08YWZHJDZ', 'B08YX8D8ST'])88get_gpu('ASUS', 'AMD Radeon RX 6800', ['B08NWJ29NB'])89get_gpu('ASUS', 'AMD Radeon RX 6900 XT', ['B08S6Z2HGW', 'B08R81J62G'])90# XFX91get_gpu('XFX', 'AMD Radeon RX 570', ['B077VX31FZ'])92get_gpu('XFX', 'AMD Radeon RX 580', ['B06Y66K3XD'])93get_gpu('XFX', 'AMD Radeon RX 5500 XT', ['B082KYFDYC'])94get_gpu('XFX', 'AMD Radeon RX 5600 XT', ['B086PZGTHZ'])95get_gpu('XFX', 'AMD Radeon RX 5700 XT', ['B082MQ4QTZ', 'B07WRYC3MT'])96get_gpu('XFX', 'AMD Radeon RX 6700 XT', ['B08YK97LKC', 'B08YKH7VMN'])97get_gpu('XFX', 'AMD Radeon RX 6800', ['B08NN76VJD'])98get_gpu('XFX', 'AMD Radeon RX 6800 XT', ['B08NX14LV1', 'B08N6ZLX9B'])99get_gpu('XFX', 'AMD Radeon RX 6900 XT', ['B08SVZNFWR', 'B08Q9SCPGD'])100# Sapphire101get_gpu('Sapphire', 'AMD Radeon RX 570', ['B079VSD38Y', 'B089V8D54S', 'B083R4XQSH', 'B071CF1JFV', 'B071XNH5BC'])102get_gpu('Sapphire', 'AMD Radeon RX 580', ['B083W2JP4W', 'B06ZZ6FMF8', 'B071QX74F9'])103get_gpu('Sapphire', 'AMD Radeon RX 5500 XT', ['B082G2YY99', 'B00JRKKSTC'])104get_gpu('Sapphire', 'AMD Radeon RX 5600 XT', ['B083R25Z94'])105get_gpu('Sapphire', 'AMD Radeon RX 5700 XT', ['B07WC7683C', 'B07XMNGVVD', 'B081KRC1H2'])106get_gpu('Sapphire', 'AMD Radeon RX 6700 XT', ['B08YN79ZW2', 'B08YNQ4ZM1'])107get_gpu('Sapphire', 'AMD Radeon RX 6800', ['B08NXYBVDB'])108get_gpu('Sapphire', 'AMD Radeon RX 6800 XT', ['B08NXXT7WN'])109get_gpu('Sapphire', 'AMD Radeon RX 6900 XT', ['B08QQFW9YS'])110# Gigabyte111get_gpu('Gigabyte', 'NVIDIA Geforce GTX 1030', ['B071DY2VJR'])112get_gpu('Gigabyte', 'NVIDIA Geforce GTX 1050 Ti', ['B01M25X363', 'B01M4KGTNI', 'B06WWLWWJM'])113get_gpu('Gigabyte', 'NVIDIA Geforce GTX 1650', ['B07QHGKC2D', 'B086T6W63R'])114get_gpu('Gigabyte', 'NVIDIA Geforce GTX 1660', ['B07P76G428'])115get_gpu('Gigabyte', 'NVIDIA Geforce GTX 1660 Ti', ['B07NJPKZQG'])116get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2060', ['B07NYKD5FT'])117get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2060 Super', ['B085CP6W5Y'])118get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2070', ['B08K3B3VPF', 'B07WGQT52X', 'B07R726461'])119get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2070 Super', ['B07WN6RVHH', 'B07WN6WB4G'])120get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2080 Super', ['B07WQG7S5S'])121get_gpu('Gigabyte', 'NVIDIA Geforce RTX 2080 Ti', ['B07YLDH9KT', 'B07GJKR7RW'])122get_gpu('Gigabyte', 'NVIDIA Geforce RTX 3060', ['B08X4V8N5Q', 'B0971BG25M'])123get_gpu('Gigabyte', 'NVIDIA Geforce RTX 3070', ['B098Q4M4WH', 'B096YM573B'])124get_gpu('Gigabyte', 'NVIDIA Geforce RTX 3080 Ti', ['B083HZF4GV'])125get_gpu('Gigabyte', 'NVIDIA Geforce RTX 3090', ['B08KTWVHQP', 'B08R5D3374', 'B08HJRF2CN'])126get_gpu('Gigabyte', 'AMD Radeon RX 570', ['B06Y3RT952'])127get_gpu('Gigabyte', 'AMD Radeon RX 580', ['B0842VMKM5', 'B06Y3ZQPY6'])128get_gpu('Gigabyte', 'AMD Radeon RX 5500 XT', ['B082BXNYCQ'])129get_gpu('Gigabyte', 'AMD Radeon RX 5600 XT', ['B083YJFHFH'])130get_gpu('Gigabyte', 'AMD Radeon RX 5700 XT', ['B0842SCK5T', 'B07W95D5V3'])131get_gpu('Gigabyte', 'AMD Radeon RX 6700 XT', ['B08Z5M4KFM'])132get_gpu('Gigabyte', 'AMD Radeon RX 6800', ['B08NYLMBJY'])133get_gpu('Gigabyte', 'AMD Radeon RX 6800 XT', ['B08PFX6PZ6'])134get_gpu('Gigabyte', 'AMD Radeon RX 6900 XT', ['B083HZ3M1X'])135# ZOTAC136get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1030', ['B0711NWFJX'])137get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1050 ti', ['B01MCU1ERO', 'B01M27X994'])138get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1060', ['B01KKJAJM4'])139get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1650', ['B07QF1H9YR', 'B0881YZJ45'])140get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1650 Super', ['B07ZKSZ5LF'])141get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1660', ['B07XV7FNR2', 'B07PF8YTCX', 'B07PD2LG7Z'])142get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1660 Super', ['B07Z8PWC6R'])143get_gpu('ZOTAC', 'NVIDIA Geforce GTX 1660 Ti', ['B07NMWQXLR'])144get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2060', ['B07TDN1SC5'])145get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2060 Super', ['B07TMJJVQ1'])146get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2070', ['B07JB9YY8V', 'B07JCRHKCL'])147get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2070 Super', ['B07XSPWMP9'])148get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2080', ['B07NC8J9YF', 'B07K9SCJRK', 'B07GG9L5X1', 'B07KB9S34G'])149get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2080 Super', ['B07TKFMHB4', 'B07WZFXVGT'])150get_gpu('ZOTAC', 'NVIDIA Geforce RTX 2080 Ti', ['B07KB1RFPW', 'B07KB86GYZ'])151get_gpu('ZOTAC', 'NVIDIA Geforce RTX 3060', ['B08W8DGK3X'])152get_gpu('ZOTAC', 'NVIDIA Geforce RTX 3070', ['B08W44ZLRP'])153get_gpu('ZOTAC', 'NVIDIA Geforce RTX 3070 Ti', ['B096TZHXYN'])154get_gpu('ZOTAC', 'NVIDIA Geforce RTX 3080 Ti', ['B0971RHNLP', 'B0964DB2P9'])...

Full Screen

Full Screen

core.py

Source:core.py Github

copy

Full Screen

1import numpy as np2import pycl3import collections4import ctree5def get_gpu():6 try:7 name = None8 gpu_id = None9 if ctree.CONFIG.has_option("opencl", "gpu"):10 name = ctree.CONFIG.get("opencl", "gpu")11 if ctree.CONFIG.has_option("opencl", "gpu_id"):12 gpu_id = ctree.CONFIG.get("opencl", "gpu_id")13 if not (gpu_id or name):14 return pycl.clGetDeviceIDs(device_type=pycl.CL_DEVICE_TYPE_GPU)[0]15 else:16 for gpu in pycl.clGetDeviceIDs():17 if gpu.name == name:18 return gpu19 if gpu.value == gpu_id:20 return gpu21 except (pycl.DeviceNotFoundError, KeyError):22 return None23class MappedArray(np.ndarray):24 queues = {}25 existing = {}26 @staticmethod27 def hash_array(arr):28 return arr.__array_interface__['data']29 def __allocate_buffer(self, device=get_gpu()):30 queue = self.get_queue(device)31 self.__buffers[device.value], evt = pycl.buffer_from_ndarray(queue, self, self.get_buffer(device))32 return evt33 def __is_dirty(self, device=get_gpu()):34 if hasattr(device, "value"):35 return self.dirty[device.value]36 return self.dirty[device]37 def __copied(self, device=get_gpu()):38 if hasattr(device, "value"):39 return self.copied[device.value]40 return self.copied[device]41 def __set_copied(self, device=get_gpu(), val=True):42 if hasattr(device, "value"):43 self.copied[device.value] = val44 else:45 self.copied[device] = val46 def set_dirty(self, device=get_gpu(), dirty=True):47 if hasattr(device, "value"):48 self.dirty[device.value] = dirty49 else:50 self.dirty[device] = dirty51 @classmethod52 def get_queue(cls, device=get_gpu()):53 if device.value in cls.queues:54 return cls.queues[device.value]55 else:56 ctx = pycl.clCreateContext(devices=[device])57 queue = pycl.clCreateCommandQueue(context=ctx, device=device)58 cls.queues[device.value] = queue59 return queue60 def device_to_gpu(self, device=get_gpu(), wait=True, force=False):61 if self.__copied(device) and not self.__is_dirty(device) and not force:62 return63 print("DEVICE TO GPU")64 evt = self.__allocate_buffer(device)65 if wait:66 evt.wait()67 else:68 self.__waiting.append(evt)69 self.set_dirty(device, False)70 self.__set_copied(device, True)71 def gpu_to_device(self, device=get_gpu(), wait=True, force=False):72 if not self.__is_dirty("host") and not force:73 return74 print("GPU to DEVICE")75 _, evt = pycl.buffer_to_ndarray(self.get_queue(device), self.__buffers[device.value], out=self)76 if wait:77 evt.wait()78 else:79 self.__waiting.append(evt)80 self.set_dirty('host', False)81 def get_buffer(self, device=get_gpu()):82 return self.__buffers.get(device.value)83 def __array_finalize__(self, obj):84 if self.hash_array(obj) in self.existing:85 old = self.existing[self.hash_array(obj)]86 self.dirty = old.dirty87 self.copied = old.copied88 self.__buffers = old.__buffers89 self.__waiting = old.__waiting90 return91 elif not hasattr(self, "dirty"):92 self.__buffers = {}93 self.__waiting = []94 self.dirty = collections.defaultdict(lambda: True)95 self.copied = collections.defaultdict(bool)...

Full Screen

Full Screen

gpu_service.py

Source:gpu_service.py Github

copy

Full Screen

...8 def get_number_of_gpus() -> int:9 return pyamdgpuinfo.detect_gpus()10 @staticmethod11 def get_model(gpu_index: int) -> str:12 model=pyamdgpuinfo.get_gpu(gpu_index).name13 if model is not None:14 return model15 else:16 slot = pyamdgpuinfo.get_gpu(gpu_index).pci_slot[5:]17 model= subprocess.getstatusoutput("lspci | grep -i "+slot+" | cut -d ':' -f3")[1]18 return model19 @staticmethod20 def get_vram(gpu_index: int) -> str:21 vram_size = GpuService._get_vram_size(gpu_index)22 return '{} {}'.format(GpuService._convert_bytes_to_mbytes(vram_size), 'MB')23 @staticmethod24 def get_vram_usage(gpu_index: int) -> str:25 vram_usage = pyamdgpuinfo.get_gpu(gpu_index).query_vram_usage()26 return '{} {}'.format(GpuService._convert_bytes_to_mbytes(vram_usage), 'MB')27 @staticmethod28 def get_temp(gpu_index: int) -> str:29 return '{} ºC'.format(pyamdgpuinfo.get_gpu(gpu_index).query_temperature())30 @staticmethod31 def get_slot(gpu_index: int) -> str:32 return pyamdgpuinfo.get_gpu(gpu_index).pci_slot33 @staticmethod34 def get_slck(gpu_index: int) -> str:35 sclk = GpuService._get_freq(gpu_index, 'S')36 return '{} MHz'.format(sclk)37 @staticmethod38 def get_mlck(gpu_index: int) -> str:39 mclk = GpuService._get_freq(gpu_index, 'M')40 return '{} MHz'.format(mclk)41 42 @staticmethod43 def _get_vram_size(gpu_index: int) -> str:44 return pyamdgpuinfo.get_gpu(gpu_index).memory_info['vram_size']45 @staticmethod46 def _get_mem_usage_size(gpu_index: int) -> str:47 return pyamdgpuinfo.get_gpu(gpu_index).query_vram_usage()48 @staticmethod49 def _get_freq(gpu_index: int, freq_type: str):50 freq = 0;51 if freq_type == 'S':52 freq = pyamdgpuinfo.get_gpu(gpu_index).query_sclk()53 elif freq_type == 'M':54 freq = pyamdgpuinfo.get_gpu(gpu_index).query_mclk()55 return round(float(freq)/1000.0**2)56 @staticmethod57 def _convert_bytes_to_gbytes(vram_size):58 return round(float(vram_size)/1024.0**3)59 60 @staticmethod61 def _convert_bytes_to_mbytes(vram_size):...

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