当前位置:   article > 正文

MAC下pytorch安装_mac下安装torch-1.13.1-cp37-none-macosx_10_9_x86_64.wh

mac下安装torch-1.13.1-cp37-none-macosx_10_9_x86_64.whl

1、安装环境

  • 系统:macOS
  • python版本:python3.8.5(python系统自带python2.7,通过pyenv安装)
  • 辅助工具:pyenv  virtualenv virtualenvwrapper

2、下载离线pytorch

https://download.pytorch.org/whl/torch_stable.html

https://download.pytorch.org/whl/cpu/torch-1.6.0-cp38-none-macosx_10_9_x86_64.whl

3、安装pyenv、virtualenv、virtualenvwrapper


pip install pyenv

或者:

git clone https://github.com/yyuu/pyenv.git ~/.pyenv

添加环境变量:

  1. ╭─nile@nilematoiMac ~/virtualenv_wk
  2. ╰─$ vim ~/.zshrc
  1. #pyenv
  2. export PYENV_ROOT="$HOME/.pyenv"
  3. export PATH="$PYENV_ROOT/bin:$PATH"
  4. eval "$(pyenv init -)"
  1. ╭─nile@nilematoiMac ~/virtualenv_wk
  2. ╰─$ source ~/.zshrc

安装python3.8.5

由于官方源太慢,修改国内源

  1. ─nile@nilematoiMac ~/.pyenv/plugins/python-build/share/python-build ‹master*
  2. ╰─$ vim 3.8.5
  1. #require_gcc
  2. prefer_openssl11
  3. export PYTHON_BUILD_CONFIGURE_WITH_OPENSSL=1
  4. install_package "openssl-1.1.0j" "https://www.openssl.org/source/old/1.1.0/openssl-1.1.0j.tar.gz#31bec6c203ce1a8e93d5994f4ed304c63ccf07676118b6634edded12ad1b3246" mac_openssl --if has_broken_mac_openssl
  5. install_package "readline-8.0" "https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz#e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461" mac_readline --if has_broken_mac_readline
  6. if has_tar_xz_support; then
  7. install_package "Python-3.8.5" "https://npm.taobao.org/mirrors/python/3.8.5/Python-3.8.5.tar.xz#e3003ed57db17e617acb382b0cade29a248c6026b1bd8aad1f976e9af66a83b0" ldflags_dirs standard verify_py38 copy_python_gdb ensurepip
  8. else
  9. install_package "Python-3.8.5" "https://npm.taobao.org/mirrors/python/3.8.5/Python-3.8.5.tgz#015115023c382eb6ab83d512762fe3c5502fa0c6c52ffebc4831c4e1a06ffc49" ldflags_dirs standard verify_py38 copy_python_gdb ensurepip

https://www.python.org/ftp/python/

替换为:

https://npm.taobao.org/mirrors/python/

  1. ╭─nile@nilematoiMac ~/.pyenv/plugins/python-build/share/python-build ‹master*
  2. ╰─$ pyenv versions
  3. * system (set by /Users/nile/.pyenv/version)
  4. 2.7.14
  5. 3.8.5

在3.8.5版本下安装

  1. pyenv shell 3.8.5
  2. pip install virtualenv -i https://mirrors.aliyun.com/pypi/simple/
  3. pip install virtualenvwrapper -i https://mirrors.aliyun.com/pypi/simple/
source ~/.pyenv/versions/3.8.5/bin/virtualenvwrapper.sh
  1. ╭─nile@nilematoiMacmkvirtualenv pytorch
  2. ╭─nile@nilematoiMac ~/virtualenv_wk
  3. ╰─$ lsvirtualenv -b
  4. pytorch
  5. ╭─nile@nilematoiMac ~/virtualenv_wk
  6. ╰─$ workon pytorch
  7. (pytorch) ╭─nile@nilematoiMac ~/virtualenv_wk
  8. ╰─$

4、安装pytorch

 

pip install torch-1.6.0-cp38-none-macosx_10_9_x86_64.whl -i https://mirrors.aliyun.com/pypi/simple/

 

pip install torchvision -i https://mirrors.aliyun.com/pypi/simple/
  1. (pytorch) ╭─nile@nilematoiMac ~/virtualenv_wk
  2. ╰─$ python
  3. Python 3.8.5 (default, Aug 19 2020, 23:39:26)
  4. [Clang 9.0.0 (clang-900.0.39.2)] on darwin
  5. Type "help", "copyright", "credits" or "license" for more information.
  6. >>> import torch
  7. >>>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/193979
推荐阅读
相关标签
  

闽ICP备14008679号