五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網 會員登陸 & 注冊

yolov5修改dml運行代碼

2023-09-14 14:46 作者:pzqking  | 我要投稿

def select_device(device='', batch_size=0, newline=True):

? ? # device = None or 'cpu' or 0 or '0' or '0,1,2,3'

? ? s = f'YOLOv5 ?? {git_describe() or file_date()} Python-{platform.python_version()} torch-{torch.__version__} '

? ? device = str(device).strip().lower().replace('cuda:', '').replace('none', '')? # to string, 'cuda:0' to '0'

? ? dml = device == 'dml'#設置使用dml

? ? cpu = device == 'cpu'

? ? mps = device == 'mps'? # Apple Metal Performance Shaders (MPS)

? ? if cpu or mps or dml:

? ? ? ? os.environ['CUDA_VISIBLE_DEVICES'] = '-1'? # force torch.cuda.is_available() = False

? ? elif device:? # non-cpu device requested

? ? ? ? os.environ['CUDA_VISIBLE_DEVICES'] = device? # set environment variable - must be before assert is_available()

? ? ? ? assert torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(',', '')), \

? ? ? ? ? ? f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)"

? ? if dml and torch_directml.is_available():

? ? ? ? devices=torch_directml.device(0)#啟用0號dml設備,在這可以更換使用的設備

? ? ? ? n=0

? ? ? ? s+=r"dml:"+str(torch_directml.device_name(0))

? ? ? ? arg=torch_directml.device(0)

? ? elif not cpu and not mps and torch.cuda.is_available():? # prefer GPU if available

? ? ? ? devices = device.split(',') if device else '0'? # range(torch.cuda.device_count())? # i.e. 0,1,6,7

? ? ? ? n = len(devices)? # device count

? ? ? ? if n > 1 and batch_size > 0:? # check batch_size is divisible by device_count

? ? ? ? ? ? assert batch_size % n == 0, f'batch-size {batch_size} not multiple of GPU count {n}'

? ? ? ? space = ' ' * (len(s) + 1)

? ? ? ? for i, d in enumerate(devices):

? ? ? ? ? ? p = torch.cuda.get_device_properties(i)

? ? ? ? ? ? s += f"{'' if i == 0 else space}CUDA:s0sssss00s ({p.name}, {p.total_memory / (1 << 20):.0f}MiB)\n"? # bytes to MB

? ? ? ? arg = 'cuda:0'

? ? elif mps and getattr(torch, 'has_mps', False) and torch.backends.mps.is_available():? # prefer MPS if available

? ? ? ? s += 'MPS\n'

? ? ? ? arg = 'mps'

? ? else:? # revert to CPU

? ? ? ? s += 'CPU\n'

? ? ? ? arg ="cpu"


? ? if not newline:

? ? ? ? s = s.rstrip()

? ? LOGGER.info(s)

? ??#print(torch.device(arg))

? ? return torch.device(arg)

#替換至utils文件夾下torch_utils.py中的select_device函數即可使用,

yolov5修改dml運行代碼的評論 (共 條)

分享到微博請遵守國家法律
阿巴嘎旗| 仪征市| 武定县| 台江县| 定南县| 儋州市| 宿迁市| 新宾| 波密县| 康乐县| 游戏| 青河县| 沿河| 洛扎县| 白沙| 财经| 潞城市| 福清市| 宣武区| 盐源县| 金华市| 庆云县| 浙江省| 呈贡县| 富民县| 江山市| 平舆县| 石台县| 高安市| 桂阳县| 响水县| 哈尔滨市| 松溪县| 启东市| 迁西县| 泊头市| 龙岩市| 济宁市| 藁城市| 康保县| 沁源县|