pytorch学习

pytorch环境搭建破事儿
隔了一个多月没用,python入门的那点知识都忘得差不多了,之前关于环境搭建的一些注意事项也忘了。导致花了一下午才重新慢慢摸索回来,太费事费力了。奇怪的是我记得我之前已经把pytorch的环境成功搭建了,也运行了数字识别程序,但是不知道为什么今天就是调不出来,老是报错。
用python3.8的时候,说和我cuba的版本不匹配,这个倒是事实。
用python3.6的时候又爆了一些莫名奇妙的错误,如图

Traceback (most recent call last):
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 2311, in next
    tarinfo = self.tarinfo.fromtarfile(self)
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 1103, in fromtarfile
    obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 1047, in frombuf
    raise InvalidHeaderError("bad checksum")
tarfile.InvalidHeaderError: bad checksum

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\serialization.py", line 556, in _load
    return legacy_load(f)
  File "E:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\serialization.py", line 467, in legacy_load
    with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 1617, in open
    return func(name, filemode, fileobj, **kwargs)
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 1647, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 1510, in __init__
    self.firstmember = self.next()
  File "E:\anaconda\envs\pytorch-gpu\lib\tarfile.py", line 2323, in next
    raise ReadError(str(e))
tarfile.ReadError: bad checksum

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:/pycharm_project/untitled7/noname.py", line 15, in <module>
    download=True)
  File "E:\anaconda\envs\pytorch-gpu\lib\site-packages\torchvision\datasets\mnist.py", line 78, in __init__
    self.data, self.targets = torch.load(os.path.join(self.processed_folder, data_file))
  File "E:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\serialization.py", line 387, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "E:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\serialization.py", line 560, in _load
    raise RuntimeError("{} is a zip archive (did you mean to use torch.jit.load()?)".format(f.name))
RuntimeError: ./num/MNIST\processed\training.pt is a zip archive (did you mean to use torch.jit.load()?)

我现在只是比较匮乏,但是我猜测应该是里面的一些函数更新了,所以现在的程序在3.6版本的python上跑不了了。
ok,言归正传,总结要点。
1.由于我的电脑cuba版本还是9.1(相当老了),据我猜测晚于9.1版本的torch和torchvision我都不能用,所以只能找9.1及以前的版本,由于9.0版本同时具有torch和torcvision,所以我这里下载的9.0版本
这俩个wenjian
2.安装方式:首先在网页上下载下来这俩包,然后把他俩放到该环境下scripts文件夹中,最后采用命令行的方式到这个文件夹中把他安装了(pip install 文件名)。这是我的个人偏好。
3.你需要什么环境,需要哪个版本的python,都可以用anaconda生成一个,然后在python创建工程时,选择那个环境就好了。
4.下载东西还要更换源。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值