国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

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運行代碼的評論 (共 條)

分享到微博請遵守國家法律
盐源县| 马鞍山市| 庆元县| 汉阴县| 文水县| 清流县| 平武县| 文昌市| 大洼县| 石景山区| 方山县| 阿拉善左旗| 徐闻县| 略阳县| 辰溪县| 麻栗坡县| 左云县| 阳谷县| 胶南市| 青岛市| 中江县| 宜兰县| 滨州市| 休宁县| 于都县| 巴彦淖尔市| 无棣县| 全椒县| 个旧市| 柳河县| 永定县| 永仁县| 延津县| 嘉定区| 毕节市| 桦甸市| 平罗县| 独山县| 青田县| 凤山县| 襄城县|