pytorch中文教程遇见问题记录

复现1:pytorch图像分类器

在学习pytorch中文教程,复现pytorch图像分类器过程中遇到的问题

问题1: torchvision包中自带的数据集下载失败问题

CIFAR
尝试过其他博主的方法将类中url地址改为本地数据集地址,但是由于新的代码文件中包含md5验证码所以未能实现
最终解决办法:
多尝试下载几次以及开加速经过两个小时的折腾终于下来了

问题2: 包缺失问题

新建的pytorch-cpu环境,环境中没有matplotlib包
切到环境中

python -m pip install matplotlib

另暂时不知道为什么直接pip install matplotlib不行,印象中其他包的安装都是直接pip install的?

问题3: 多线程问题

转自博主 https://blog.csdn.net/yaoyutian/article/details/85086129.

错误信息

RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.
 
        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:
 
            if __name__ == '__main__':
                freeze_support()
                ...
 
        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

原因:多进程需要在main函数中运行
(我操作系统学得拉,这里不知道为什么)

解决方法1
将全部操作写进main函数中
在__main__中调用该main
详见链接博客

解决方法2
将num_workers设置为0单进程加载
详见链接博客

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值