用brew安装Opencv和PyTorch安装、模型复现时碰到的一些问题 2021-08-08


用brew安装Opencv时碰到了不少问题,应该是系统自动升级到big sur时的问题,

报错1

xianyu@bogon ~ % brew install openv
==> Tapping homebrew/cask
Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask’…
fatal: unable to access ‘https://github.com/Homebrew/homebrew-cask/’: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-cask /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask --origin=origin --template= exited with 128.
xianyu@bogon ~ % git config --global --unset http.proxy

xianyu@bogon ~ % git config --global --unset https.proxy
解决方案:

git config --global --unset http.proxy
git config --global --unset https.proxy

取消http代理, 取消https代理

报错2

Error: opencv: Calling sha256 "digest" => :tag in a bottle block is disabled! Use brew style --fix on the formula to update the style or use sha256 tag: "digest" instead.
Please report this issue to the homebrew/core tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/opencv.rb:9

解决方案:

brew style --fix

报错3

Error: shellcheck: cannot load such file – language/haskell

解决方案:

brew update && brew doctor -d

然后根据提示更新PATH,然后运行

brew cleanup

解决完报错3之后再回头解决卡在报错2处的问题

重新运行

brew style --fix

提示修复成功

如果中间有提示下载失败的错误,那么重新运行一次brew安装命令就可以了

如果提示brew link出错,可以尝试运行窗口中提示的命令修复

Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink lib/libImath.dylib
Target /usr/local/lib/libImath.dylib
is a symlink belonging to ilmbase. You can unlink it:
brew unlink ilmbase

To force the link and overwrite all conflicting files:
brew link --overwrite imath

To list all files that would be deleted:
brew link --overwrite --dry-run imath

Possible conflicting files are:
/usr/local/lib/libImath.dylib -> /usr/local/Cellar/ilmbase/2.4.0/lib/libImath.dylib

PyTorch的安装

B站上有很多视频可以参考,比Blog里的文字容易理解很多,我一开始安装参考了这个视频,但是后续都是跟着PyTorch官网和Anaconda官网上的教程安装了。
链接: B站教程.

链接: PyTorch官网.

链接: Anaconda官网.

报错4

AssertionError: Torch not compiled with CUDA enabled

如果是运行Mac系统或者是其他没有安装Nvidia显卡的硬件系统,不会默认下载CUDA,这个时候需要在程序开始的地方加上:

device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)

图片: Alt

参考这两篇Blog:link 1, link 2.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值