PyTorch 1.1.0发布,官方支持TensorBoard,还有更多性能和分布式功能的提升!

点击上方“AI公园”,关注公众号,选择加“星标“或“置顶”


作者:Facebook

编译:ronghuaiyang

导读

Facebook刚刚发布了PyTorch的最新版本,PyTorch1.1.0,这是自从发布PyTorch1.0以来的又一个重大的更新


Facebook刚刚发布了PyTorch的最新版本,PyTorch1.1.0,这是自从发布PyTorch1.0以来的又一个重大的更新,在这个版本中,最最显眼的一个更新就是官方支持TensorBoard了,之前大家都是用的TensorBoardX,这次,终于可以光明正大的使用TensorBoard了,顺便吐槽一下visdom,确实不如TensorBoard好用。

除了TensorBoard之外,其实还有不少重要的更新,下面给大家提供一些摘要,给大家先过目一遍,我列出了一些要点,更多的内容大家可以去看看原文。

注意:不再支持CUDA 8.0

重点

TensorBoard (试验)

使用TensorBoard对可视化和模型调试提供一流的本地支持,这是一个用于检查和理解训练运行、张量和图的web应用程序套件。PyTorch现在支持TensorBoard通过一个简单的 fromtorch.utils.tensorboardimportSummaryWriter命令来写入日志。直方图、嵌入、标量、图像、文本、图形,以及更多东西都可以在训练过程中进行可视化。目前,TensorBoard支持还处于试验阶段。

640?wx_fmt=png

[JIT] ScriptModules中的属性

可以在 ScriptModule上分配属性,方法是用 torch.jit.Attribute指定类型。属性类似于参数或缓冲区,但可以是任何类型。当你调用 torch.jit.save()时,它们将与任何参数/缓冲区一起被序列化,因此它们是在模型中存储任意状态的好方法。

例子:

class Foo(torch.jit.ScriptModule):	
  def __init__(self, a_dict):	
    super(Foo, self).__init__(False)	
    self.words = torch.jit.Attribute([], List[str])	
    self.some_dict = torch.jit.Attribute(a_dict, Dict[str, int])	
  @torch.jit.script_method	
  def forward(self, input: str) -> int:	
    self.words.append(input)	
    return self.some_dict[input]

[JIT] 在TorchScript中支持字典和列表

TorchScript现在对列表和字典类型提供了健壮的支持。它们的行为很像Python列表和字典,支持大多数内置方法,包括简单的包含操作和 forin的构造方式。

[JIT] 在TorchScript中用户自己定义类 (试验)

对于更复杂的有状态操作,TorchScript现在支持用 @torch.jit.script标注类。使用这种方法的类可以像其他TorchScript模块一样在c++中jit编译和加载。

@torch.jit.script	
class Pair:	
    def __init__(self, first, second)	
        self.first = first	
        self.second = second	
    def sum(self):	
        return self.first + self.second

DistributedDataParallel新功能和指南

nn.parallel.DistributedDataParallel:现在可以封装multi-GPU模块,可以在一台服务器上使用模型并行,以及多台服务器上使用数据并行。

突破性的改进

  • Tensor.set_: Tensor中的 device不再可以通过 Tensor.set_来改变了. 这通常发生在使用默认CUDA设备设置Tensor,然后在另一个CUDA设备的 Storage中交换Tensor时。相反,需要从一开始就在正确的设备上建立Tensor。

  • 注意 lr_scheduler.step()的顺序更改了。

  • torch.unique: 把 sorted的默认值改成了 True.

  • [JIT] 重命名isTensor接口为isCompleteTensor.

  • [JIT] 去掉了GraphExecutor的python绑定.

  • [C++]: many methods on 在 Type上的许多方面现在不再退出了,可以使用函数或者Tensor的方法来起到同样的效果.

  • [C++]TensorOptions 的 Backend构造器不存在了. (18137).

  • [C++, Distributed]: 去掉了c10d ProcessGroup::getGroupRank 也去掉了.

Tensors / dtypes

  • torch.bool: 增加了对 torch.bool类型以及该类型张量 (存储为1-byte)的支持. 支持NumPy的转化,但是操作现在是有限制的.

优化器

  • optim.lr_scheduler.CyclicLR: 支持循环学习率和动量.

  • optim.lr_scheduler.CosineAnnealingWarmRestarts: 新的学习率策略:带热身重启的随机梯度下降.

  • 支持多个同步的学习率策略.

分布式

  • torch.distributions: 现在支持多重继承.

采样

  • quasirandom.SobolEngine: 新采样器.

DistributedDataParallel

  • nn.parallel.DistributedDataParallel: 现在支持带无用参数的模型(例如控制流,比如adaptive softmax等等).

提升

  • torch.mintorch.maxtorch.mediantorch.modetorch.kthvaluetorch.symeigtorch.eigtorch.pstrftorch.qrtorch.geqrftorch.solvetorch.slogdettorch.sorttorch.topktorch.gelstorch.triangular_solve 现在返回一个名称元组来描述输出.

  • torch.empty (还有其他的构造函数): 现在可以接受 pin_memory 参数; 现在不用 torch.Storage也可以就那些pin了.. .

  • torch.histc: 现在支持CUDA了.

  • torch.unique: 增加了 return_counts.

  • torch.logspace: 增加了指定对数底的功能.

  • torch.set_printoptions: 增加对科学计数的支持 .

  • torch.btrifact 现在可以操作超过3维的tensor.

  • torch.kthvalue: 支持CUDA.

  • torch.abs: 支持 uint8 和 int8 类型.

  • torch.stacktorch.cat: 支持CPU半精度tensors.

  • torch.cross: 支持负维度.

  • torch.lerp: 增加像支持Tensor一样支持 weight.

  • torch.transpose: 和NumPy变得一样了: 1-d和0-d数组都可以接受,返回原来一样的数组.

  • torch.linspacetorch.logspace 现在可以使用 steps=1 和 start!=end

  • torch.cholesky: 把导数从三角形矩阵变成对称矩阵.

  • torch.lerp: 提升了数值稳定性.

  • torch.logdettorch.slogdet: 提升了数值精度.

  • Tensor.__contains__ 现在支持了.

  • Tensor.fill_ 和 torch.zeros 在CPU上支持半精度.

  • Tensor.resize_as_Tensor.view: 在CPU上支持半精度.

  • Tensorindexing: 允许通过NumPy布尔值来进行索引.

  • nn.EmbeddingBag: 支持半精度密集后端.

  • nn.Embedding: 修改了密集嵌入来和双后端一起使用.

  • nn.MaxPool1d: 允许列表和元组作为 output_size输入.

  • nn.CTCLoss: 通过 zero_infinity参数可以支持对无限的损失置零.

  • nn.Dropout: 支持在eval时使能.

  • nn.MSELoss: 对不合法的广播进行告警.

  • nn.Module.load_state_dict: 增加两个返回值 missing_keys 和 unexpected_keys.

  • nn.parallel.data_parallel: 强制设备匹配 device_ids.

  • torch.device: 过去只接受设备好的地方,现在都可以用这个了.

  • dtype.int8 这个类型的tensors现在可以转换为NumPy数组了.

  • nn.functional.gumbel_softmax: 使用 dim参数运行多个维度的输入.

  • nn.functional.cosine_similarity: 提高了精度.

  • torch.autograd: 不再保存不需要的输入,提高了内存效率.

  • torch.autograd.profiler: 增加了自身的CPU时间,总的CPU时间.

  • DataLoader: 支持接受一个用户自定义的内存pinning函数.

  • DataLoader: 在EINTR重试libshm .

  • DataLoader: 修改了使用 pin_memory 和 PackedSequence的一个问题.

  • data.utils.collatedata.utils.pin_memory: 现在可以保存名字元组.

  • 在许多的索引错误情况下,使用 IndexError 代替 RuntimeError .

  • 在CPU上支持索引 torch.float16 tensor.

  • 在inplace操作上增加(有限的)错误检测.

  • utils.checkpoint.checkpoint: 支持 None 作为参数 .

  • torch.autograd:为 one of the variables neededforgradient computation has been modifiedbyan inplace operation 异常增加更多的信息.

  • cuda.synchronize: 增加一个设备参数.

  • cuda.reset_max_memory_*: 现在支持了.

  • distributions.Independent: 现在可以计算KL散度了.

  • torch.distributed.new_group: 现在支持覆盖默认的backend.

性能

重点

  • nn.BatchNorm CPU推理速度提升了最高19倍.

  • nn.AdaptiveAvgPool: size=1时通常可以加速30倍.

  • nn.EmbeddingBag CPU性能提升了4倍.

  • Tensor.copy_: 对于大的tensor拷贝加速了2~3倍.

  • torch.nonzero: 在CPU上现在比numpy块2倍.

  • 改进用于为Pascal架构和更新的GPU提升了缓存分配器的性能,Mask-RCNN的内存利用率提高了10-20%。

  • reduction functions: 对于某些大Tensor的情况下,加速了50-80%.

  • [JIT] Graph fuser: 在广播的存在下,更好地融合向后图.

  • [JIT] Graph fuser: batch_norm 推理时的融合.

  • [JIT] Graph fuser: layer_norm 推理时的融合. 

640?wx_fmt=png—END—

英文原文:https://github.com/pytorch/pytorch/releases

640?wx_fmt=jpeg

请长按或扫描二维码关注本公众号

喜欢的话,请给我个好看吧640?wx_fmt=gif

E:\Anaconda3\envs\v5ui\python.exe D:\yolov5\train.py train: weights=weights\yolov5s.pt, cfg=models/yolov5s.yaml, data=data\VOC-kuang.yaml, hyp=data\hyps\hyp.scratch.yaml, epochs=80, batch_size=8, imgsz=320, rect=False, resume=, nosave=False, noval=False, noautoanchor=False, evolve=None, bucket=, cache=false, image_weights=False, device=0, multi_scale=False, single_cls=False, adam=False, sync_bn=False, workers=2, project=runs\train, name=exp, exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, patience=100, freeze=0, save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest github: skipping check (not a git repository), for updates see https://github.com/ultralytics/yolov5 YOLOv5 2024-10-28 torch 1.10.1 CUDA:0 (NVIDIA GeForce MX450, 2047.75MB) hyperparameters: lr0=0.001, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0 TensorBoard: Start with 'tensorboard --logdir runs\train', view at http://localhost:6006/ Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 runs (RECOMMENDED) from n params module arguments 0 -1 1 3520 models.common.Conv [3, 32, 6, 2, 2] 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] 2 -1 1 18816 models.common.C3 [64, 64, 1] 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] 4 -1 2 115712 models.common.C3 [128, 128, 2] 5 -1 1 295424 models.common.Conv [128, 256, 3, 2] 6 -1 3 625152 models.common.C3 [256, 256, 3] 7 -1 1 1180672 models.common.Conv [256, 512, 3, 2] 8 -1 1 1182720 models.common.C3 [512, 512, 1] 9 -1 1 656896 models.common.SPPF [512, 512, 5] 10 -1 1 131584 models.common.Conv [512, 256, 1, 1] 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 12 [-1, 6] 1 0 models.common.Concat [1] 13 -1 1 361984 models.common.C3 [512, 256, 1, False] 14 -1 1 33024 models.common.Conv [256, 128, 1, 1] 15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 16 [-1, 4] 1 0 models.common.Concat [1] 17 -1 1 90880 models.common.C3 [256, 128, 1, False] 18 -1 1 147712 models.common.Conv [128, 128, 3, 2] 19 [-1, 14] 1 0 models.common.Concat [1] 20 -1 1 296448 models.common.C3 [256, 256, 1, False] 21 -1 1 590336 models.common.Conv [256, 256, 3, 2] 22 [-1, 10] 1 0 models.common.Concat [1] 23 -1 1 1182720 models.common.C3 [512, 512, 1, False] 24 [17, 20, 23] 1 21576 models.yolo.Detect [3, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]] Model Summary: 270 layers, 7027720 parameters, 7027720 gradients Transferred 342/349 items from weights\yolov5s.pt Scaled weight_decay = 0.0005 optimizer: SGD with parameter groups 57 weight, 60 weight (no decay), 60 bias train: Scanning 'VOCdevkit\labels\train.cache' images and labels... 83 found, 0 missing, 0 empty, 0 corrupted: 100%|██████████| 83/83 [00:00<?, ?it/s] train: Caching images (0.0GB false): 100%|██████████| 83/83 [00:00<00:00, 910.73it/s] val: Scanning 'VOCdevkit\labels\val.cache' images and labels... 29 found, 0 missing, 0 empty, 0 corrupted: 100%|██████████| 29/29 [00:00<?, ?it/s] val: Caching images (0.0GB false): 100%|██████████| 29/29 [00:00<00:00, 782.47it/s] Plotting labels... autoanchor: Analyzing anchors... anchors/target = 5.36, Best Possible Recall (BPR) = 1.0000 Image sizes 320 train, 320 val Using 2 dataloader workers Logging results to runs\train\exp19 Starting training for 80 epochs... Epoch gpu_mem box obj cls labels img_size 0/79 0.457G nan nan nan 41 320: 100%|██████████| 11/11 [00:07<00:00, 1.50it/s] E:\Anaconda3\envs\v5ui\lib\site-packages\torch\optim\lr_scheduler.py:129: UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`. Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate warnings.warn("Detected call of `lr_scheduler.step()` before `optimizer.step()`. " Class Images Labels P R mAP@.5 mAP@.5:.95: 0%| | 0/2 [00:00<?, ?it/s]E:\Anaconda3\envs\v5ui\lib\site-packages\torch\functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ..\aten\src\ATen\native\TensorShape.cpp:2157.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 2/2 [00:00<00:00, 4.37it/s] all 29 0 0 0 0 0 Epoch gpu_mem box obj cls labels img_size 1/79 0.573G nan nan nan 38 320: 100%|██████████| 11/11 [00:03<00:00, 2.75it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 2/2 [00:00<00:00, 4.47it/s] all 29 0 0 0 0 0 Epoch gpu_mem box obj cls labels img_size 2/79 0.573G nan nan nan 18 320: 100%|██████████| 11/11 [00:03<00:00, 2.94it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 2/2 [00:00<00:00, 4.38it/s] all 29 0 0 0 0 0 Epoch gpu_mem box obj cls labels img_size 3/79 0.575G nan nan nan 16 320: 100%|██████████| 11/11 [00:03<00:00, 2.90it/s] Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 2/2 [00:00<00:00, 4.55it/s] all 29 0 0 0 0 0
最新发布
05-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值