ERROR: torch-1.6.0+cu101-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

目的:使用混合精度训练模型
方法:最新版pytorch1.6已封装进混合量化的模块,只需几句代码就可以提高batch size,速度会有非常大的提升。
安装pytorch:

pip install torch-1.6.0+cu101-cp37-cp37m-win_amd64.whl

报错:

DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
WARNING: Requirement 'torch-1.6.0+cu101-cp37-cp37m-win_amd64.whl' looks like a filename, but the file does not exist
ERROR: torch-1.6.0+cu101-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

查了一下,应该是python版本的问题,
最新的pytorch1.6版本需要安装python3.7,我的python是3.5,遂安装3.7,linux安装3.7参考https://www.cnblogs.com/guo2733/p/11459144.html
结果报错:

ModuleNotFoundError: No module named '_ctypes'
Makefile:1122: recipe for target 'install' failed
make: *** [install] Error 1

解决方法:参考https://blog.csdn.net/wang725/article/details/79905612
一般都是让更新,安装libffi-dev,但更新还有评论里的方法试了都不行,运行更新报错:

root@98ac4a9e8de7:/usr/local/python3# apt-get update
Get:1 file:/var/nvinfer-runtime-trt-repo-4.0.1-ga-cuda9.0  InRelease
Ign:1 file:/var/nvinfer-runtime-trt-repo-4.0.1-ga-cuda9.0  InRelease
Get:2 file:/var/nvinfer-runtime-trt-repo-4.0.1-ga-cuda9.0  Release [574 B]
Get:2 file:/var/nvinfer-runtime-trt-repo-4.0.1-ga-cuda9.0  Release [574 B]
Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Ign:7 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  InRelease
Get:8 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]
Ign:9 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  InRelease
Get:10 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release [169 B]
Hit:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64  Release
Get:13 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Release.gpg [169 B]
Ign:14 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
Get:14 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages [327 kB]
Ign:14 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
Get:14 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages [1382 kB]
Err:14 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
  Writing more data than expected (1383659 > 1382106)
Fetched 327 kB in 25s (12.9 kB/s)
Reading package lists... Done
E: Failed to fetch https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/Packages  Writing more data than expected (1383659 > 1382106)
E: Some index files failed to download. They have been ignored, or old ones used instead.

换源操作后,更新这边还是有问题,但重新编译了一遍python,安装上了…
不过pip3报错:

root@98ac4a9e8de7:/home/work/gaotong/datasets# python3 -V
Python 3.7.1
root@98ac4a9e8de7:/home/work/gaotong/datasets# pip3 -V
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in 
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli'

发现下面这句可以成功运行,

pip3 install jieba -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
root@98ac4a9e8de7:/usr/local/python3/Python-3.7.1# pip3 install jieba -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple/
Collecting jieba
  Downloading http://pypi.doubanio.com/packages/c6/cb/18eeb235f833b726522d7ebed54f2278ce28ba9438e3135ab0278d9792a2/jieba-0.42.1.tar.gz (19.2MB)
    100% |████████████████████████████████| 19.2MB 1.9MB/s
Installing collected packages: jieba
  Running setup.py install for jieba ... done
Successfully installed jieba-0.42.1

所以先安装了torch1.5.

pip3 install torch==1.5.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

再安装完opencv-python后,导入cv2会报错,还是

root@98ac4a9e8de7:/home/work/gaotong/datasets/Living_Body/pytorch/anti-spoofing_depth# python3
Python 3.7.1 (default, Sep 28 2020, 07:00:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

参考博客:https://blog.csdn.net/qq_35516745/article/details/103822597
问题完美解决。

你可能感兴趣的:(日常bug系列)