https://blog.csdn.net/qq_40349484/article/details/110632113?spm=1001.2014.3001.5502
前面步骤按照上述链接来。
pip install ninja yacs cython matplotlib tqdm opencv-python overrides -i https://pypi.tuna.tsinghua.edu.cn/simple/
在这一步,安装opencv-python会卡住
Running setup.py bdist_wheel for opencv-python …
- 解决:更新pip
https://blog.csdn.net/weixin_44112313/article/details/123127509
之后,再次卡住
Building wheel for opencv-python (PEP 517) …
- 解决:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-build cmake
然后会卡在Building wheels for collected packages: opencv-python
Building wheel for opencv-python (pyproject.toml)
经过一段时间等待,报错ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
- 解决:
https://blog.csdn.net/qq_41821678/article/details/128913990
pip install -i https://pypi.douban.com/simple/ pip install opencv-python==4.3.0.38
opencv-python安装成功
按照原链接博主给的安装torch,但是torch.cuda.is_available()显示false,当时继续后面的内容了,但是后面有报错,根据报错更新了torch版本,然后发现显示true了!
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
解决:https://blog.csdn.net/qq_34211771/article/details/120625282
(后续证明不要轻易换pytorch版本,之后如果报错RuntimeError: Error compiling objects for extension,则是pytorch版本不合适的问题。github的issue里都是用torch1.4成功的,其他版本的torch会报错)
发现使用conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1
安装的时候,系统自动会匹配torch1.4的cpu版本,估计之前安装torch的时候没注意看,可能这是我当时cuda显示false的原因
解决:https://windses.blog.csdn.net/article/details/125910538?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-125910538-blog-123876539.pc_relevant_multi_platform_whitelistv3&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-125910538-blog-123876539.pc_relevant_multi_platform_whitelistv3&utm_relevant_index=1
在镜像里确实找到了py3.6+torch1.4+cuda10.1的版本,但是就是匹配不上,所以指定下载链接
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/linux-64/
但是用这个镜像安装的pytorch,明明在conda list
是显示有pytorch的,但是在python里会报错ModuleNotFoundError: No module named ‘torch‘- 解决:打开https://download.pytorch.org/whl/torch_stable.html,找到cu101+py3.6+torch1.4.0和cu101+py3.6+torchvision0.5.0的whl,分别使用
pip install https://download.pytorch.org/whl/cu101/torch-1.4.0-cp36-cp36m-win_amd64.whl
pip install https://download.pytorch.org/whl/cu101/torchvision-0.5.0-cp36-cp36m-win_amd64.whl
成功安装,cuda显示true
安装torch1.4.0+torchvision0.5.0+cuda10.1,后续一直到python webcam.py都不会再报错,安装非常顺利
在图中这一步运行后报错
cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”
error: command ‘C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x64\cl.exe’ failed with exit status 2
- 解决:https://blog.csdn.net/qq_41185868/article/details/103897966
subprocess.CalledProcessError: Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1
- 解决:
https://blog.csdn.net/qing666888/article/details/83246992
之前把include和lib的放在了path里面,所以没有用
最后报错RuntimeError: Error compiling objects for extension
- 解决:放弃,因为我的win电脑是30显卡,ninja和pytorch不匹配,具体看https://blog.csdn.net/qq_40349484/article/details/123635244 的评论