PyTorch库使用常见的问题集锦(不断完善中)

问题1:AttributeError: ‘_MultiProcessingDataLoaderIter’ object has no attribute ‘_send_idx’

  • 问题原因:data.DataLoader没有属性’_send_idx’
    出现这个问题,最大的可能性是因为,torch的版本太低,建议升级Pytorch的版本,本人的版本是torch=1.3.0 torchvision=0.4.1
  • 解决策略:
    • 方法1:重现安装pytorchpip install torch==1.3.0 torchvision==0.4.1 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
    • 方法2:在https://download.pytorch.org/whl/torch_stable.html网页下载需要的PyTorch 和 torchvision 版本(注意:cuda 的版本和 Python 的版本相对应)
      安装命令:pip install home/jankin/torch-1.3.0-cp35-cp35m-linux_x86_64.whl

相似问题1.1:AssertionError:The NVIDIA driver on your system is too old (found version 8000).

version from the URL: Download Drivers
Alternatively, go to: PyTorch to install
a PyTorch version that has been compiled with your version
of the CUDA driver.
  • 问题原因: PyTorch 与 CUDA 的版本不匹配
  • 解决策略:同上述方法。

问题2:RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50

  • 问题原因:Pytorch的版本不太合适
  • 解决策略:重新安装pytorch>=1.1 <1.3的版本

问题3:RuntimeError: cuda runtime error (38) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50

  • 问题原因:无法调用本机的cuda。
  • 解决策略:(1)查看是否是本机的显卡驱动没有安装好,检测命令nvidia-smi,若是本机的驱动没有安装好,请重新安装驱动。

问题4:AttributeError: ‘DataParallel’ object has no attribute ‘vocab’

  • 问题原因:使用多卡训练,无法调用部分模块
  • 解决策略:改为 model.module
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值