用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”)
图片: