美文网首页
如何在Mac上安装TensorFlow

如何在Mac上安装TensorFlow

作者: leogoforit | 来源:发表于2020-03-19 17:24 被阅读0次

如题:如何在Mac上安装TensorFlow

按照搜索出来的中文教程没有安装成功的,后来在youtube上有一个叫Jeff heaton(你没看错,不是那个Geoffrey Hinton)的教授发布了教程2020, Installing TensorFlow 2.0, Keras, & Python 3.7 in Mac OSX按他说的一步一步来,安装成功了。

1、 点击下载minconda

如下图,选择红框中的版本,一步步安装就可以。


选择红框中的版本

2、通过conda安装Jupyter

terminal里输入:
conda install jupyter

3、下载环境安装脚本

github上搜索Jeff heaton,找到 t81_558_deep_learning仓库,划到最下方找到tensorflow.yml,用浏览器打开后点击保存在你用户名的文件夹下。

4、创建环境

terminal里输入:
conda env create -v -f tensorflow.yml
输入后正确的显示如下:

Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done
initializing UnlinkLinkTransaction with
  target_prefix: /Users/leo/opt/miniconda3/envs/tensorflow
  unlink_precs:
    
  link_precs:
    defaults/osx-64::_tflow_select-2.3.0-mkl
    defaults/osx-64::blas-1.0-mkl
    defaults/osx-64::c-ares-1.15.0-h1de35cc_1001
    defaults/osx-64::ca-certificates-2020.1.1-0
    defaults/osx-64::intel-openmp-2019.4-233
    defaults/osx-64::jpeg-9b-he5867d9_2
    defaults/osx-64::libcxxabi-4.0.1-hcfea43d_1
    defaults/osx-64::libgfortran-3.0.1-h93005f0_2
    defaults/osx-64::libiconv-1.15-hdd342a3_7
    defaults/osx-64::libsodium-1.0.16-h3efe00b_0
    defaults/osx-64::llvm-openmp-4.0.1-hcfea43d_1
    defaults/osx-64::pandoc-2.2.3.2-0
    defaults/osx-64::xz-5.2.4-h1de35cc_4
    defaults/osx-64::yaml-0.1.7-hc338f04_2
    defaults/osx-64::zlib-1.2.11-h1de35cc_3
    defaults/osx-64::libcxx-4.0.1-hcfea43d_1
    defaults/osx-64::libpng-1.6.37-ha441bb4_0
    defaults/osx-64::libxml2-2.9.9-hf6e021a_1
    defaults/osx-64::mkl-2019.4-233
    defaults/osx-64::openssl-1.1.1e-h1de35cc_0
    defaults/osx-64::tk-8.6.8-ha441bb4_0
    defaults/osx-64::zstd-1.3.7-h5bba6e5_0
    defaults/osx-64::expat-2.2.6-h0a44026_0
    defaults/osx-64::freetype-2.9.1-hb4e5f40_0
    defaults/osx-64::hdf5-1.10.4-hfa1e0ec_0
    defaults/osx-64::icu-58.2-h4b95b61_1
    defaults/osx-64::libffi-3.2.1-h475c297_4
    defaults/osx-64::libprotobuf-3.11.4-hd9629dc_0
    defaults/osx-64::libtiff-4.1.0-hcb84e12_0
    defaults/osx-64::ncurses-6.2-h0a44026_0
    defaults/osx-64::pcre-8.43-h0a44026_0
    defaults/osx-64::zeromq-4.3.1-h0a44026_3
    defaults/osx-64::gettext-0.19.8.1-h15daf44_3
    defaults/osx-64::libedit-3.1.20181209-hb402a30_0
    defaults/osx-64::libxslt-1.1.33-h33a18ac_0
    defaults/osx-64::readline-7.0-h1de35cc_5
    defaults/osx-64::glib-2.63.1-hd977a24_0
    defaults/osx-64::sqlite-3.31.1-ha441bb4_0
    defaults/osx-64::dbus-1.13.12-h90a0687_0
    defaults/osx-64::python-3.7.6-h359304d_2
    defaults/osx-64::qt-5.9.7-h468cd18_1
    defaults/osx-64::appnope-0.1.0-py37_0
    defaults/osx-64::asn1crypto-1.3.0-py37_0
    defaults/osx-64::astor-0.8.0-py37_0
    defaults/noarch::attrs-19.3.0-py_0
    defaults/osx-64::backcall-0.1.0-py37_0
    defaults/osx-64::certifi-2019.11.28-py37_0
    defaults/osx-64::chardet-3.0.4-py37_1003
    defaults/noarch::click-7.1.1-py_0
    defaults/noarch::decorator-4.4.2-py_0
    defaults/noarch::defusedxml-0.6.0-py_0
    defaults/osx-64::docutils-0.15.2-py37_0
    defaults/osx-64::entrypoints-0.3-py37_0
    defaults/osx-64::gast-0.2.2-py37_0
    defaults/noarch::idna-2.9-py_1
    defaults/osx-64::ipython_genutils-0.2.0-py37_0
    defaults/osx-64::itsdangerous-1.1.0-py37_0
    defaults/noarch::jmespath-0.9.4-py_0
    defaults/osx-64::kiwisolver-1.1.0-py37h0a44026_0
    defaults/osx-64::lxml-4.5.0-py37hef8c89e_0
    defaults/osx-64::markupsafe-1.1.1-py37h1de35cc_0
    defaults/osx-64::mistune-0.8.4-py37h1de35cc_0
    defaults/osx-64::olefile-0.46-py37_0
    defaults/osx-64::pandocfilters-1.4.2-py37_1
    defaults/noarch::parso-0.6.2-py_0
    defaults/osx-64::pickleshare-0.7.5-py37_0
    defaults/noarch::prometheus_client-0.7.1-py_0
    defaults/osx-64::ptyprocess-0.6.0-py37_0
    defaults/noarch::pycparser-2.20-py_0
    defaults/noarch::pyparsing-2.4.6-py_0
    defaults/osx-64::pysocks-1.7.1-py37_0
    defaults/noarch::pytz-2019.3-py_0
    defaults/osx-64::pyyaml-5.3-py37h1de35cc_0
    defaults/osx-64::pyzmq-18.1.1-py37h0a44026_0
    defaults/noarch::qtpy-1.9.0-py_0
    defaults/osx-64::send2trash-1.5.0-py37_0
    defaults/osx-64::sip-4.19.8-py37h0a44026_0
    defaults/osx-64::six-1.14.0-py37_0
    defaults/osx-64::termcolor-1.1.0-py37_1
    defaults/noarch::testpath-0.4.4-py_0
    defaults/osx-64::tornado-6.0.4-py37h1de35cc_1
    defaults/noarch::tqdm-4.43.0-py_0
    defaults/noarch::wcwidth-0.1.8-py_0
    defaults/osx-64::webencodings-0.5.1-py37_1
    defaults/noarch::werkzeug-1.0.0-py_0
    defaults/osx-64::wrapt-1.12.1-py37h1de35cc_1
    defaults/noarch::zipp-2.2.0-py_0
    defaults/osx-64::absl-py-0.9.0-py37_0
    defaults/osx-64::cffi-1.14.0-py37hb5b8e2f_0
    defaults/osx-64::cycler-0.10.0-py37_0
    defaults/noarch::google-pasta-0.1.8-py_0
    defaults/osx-64::importlib_metadata-1.5.0-py37_0
    defaults/osx-64::jedi-0.16.0-py37_0
    defaults/osx-64::mkl-service-2.3.0-py37hfbe908c_0
    defaults/osx-64::pexpect-4.8.0-py37_0
    defaults/osx-64::pillow-7.0.0-py37h4655f20_0
    defaults/osx-64::pyqt-5.9.2-py37h655552a_2
    defaults/osx-64::pyrsistent-0.15.7-py37h1de35cc_0
    defaults/noarch::python-dateutil-2.8.1-py_0
    defaults/osx-64::setuptools-46.0.0-py37_0
    defaults/osx-64::terminado-0.8.3-py37_0
    defaults/osx-64::traitlets-4.3.3-py37_0
    defaults/osx-64::bleach-3.1.0-py37_0
    defaults/osx-64::cryptography-2.8-py37ha12b0ac_0
    defaults/osx-64::grpcio-1.16.1-py37h044775b_1
    defaults/noarch::jinja2-2.11.1-py_0
    defaults/noarch::joblib-0.14.1-py_0
    defaults/osx-64::jsonschema-3.2.0-py37_0
    defaults/osx-64::jupyter_core-4.6.1-py37_0
    defaults/osx-64::markdown-3.1.1-py37_0
    defaults/osx-64::numpy-base-1.18.1-py37h6575580_1
    defaults/osx-64::protobuf-3.11.4-py37h0a44026_0
    defaults/noarch::pygments-2.6.1-py_0
    defaults/osx-64::wheel-0.34.2-py37_0
    defaults/noarch::flask-1.1.1-py_0
    defaults/noarch::jupyter_client-6.0.0-py_0
    defaults/noarch::nbformat-5.0.4-py_0
    defaults/osx-64::pip-20.0.2-py37_1
    defaults/noarch::prompt_toolkit-3.0.3-py_0
    defaults/osx-64::pyopenssl-19.1.0-py37_0
    defaults/osx-64::ipython-7.13.0-py37h5ca1d4c_0
    defaults/osx-64::nbconvert-5.6.1-py37_0
    defaults/osx-64::urllib3-1.25.8-py37_0
    defaults/noarch::botocore-1.15.12-py_0
    defaults/osx-64::ipykernel-5.1.4-py37h39e3cac_0
    defaults/osx-64::requests-2.23.0-py37_0
    defaults/noarch::jupyter_console-6.1.0-py_0
    defaults/osx-64::notebook-6.0.3-py37_0
    defaults/noarch::qtconsole-4.7.1-py_0
    defaults/osx-64::s3transfer-0.3.3-py37_0
    defaults/noarch::boto3-1.12.12-py_0
    defaults/osx-64::widgetsnbextension-3.5.1-py37_0
    defaults/noarch::ipywidgets-7.5.1-py_0
    defaults/osx-64::jupyter-1.0.0-py37_7
    defaults/noarch::opt_einsum-3.1.0-py_0
    defaults/noarch::pandas-datareader-0.8.1-py_0
    defaults/noarch::tensorboard-2.0.0-pyhb38c66f_1
    defaults/noarch::tensorflow-estimator-2.0.0-pyh2649769_0
    defaults/osx-64::h5py-2.10.0-py37h3134771_0
    defaults/noarch::keras-applications-1.0.8-py_0
    defaults/osx-64::matplotlib-3.1.3-py37_0
    defaults/osx-64::matplotlib-base-3.1.3-py37h9aa3819_0
    defaults/osx-64::mkl_fft-1.0.15-py37h5e564d8_0
    defaults/osx-64::mkl_random-1.1.0-py37ha771720_0
    defaults/osx-64::numpy-1.18.1-py37h7241aed_0
    defaults/osx-64::pandas-1.0.2-py37h6c726b0_0
    defaults/osx-64::scipy-1.4.1-py37h9fa6033_0
    defaults/noarch::keras-preprocessing-1.1.0-py_1
    defaults/osx-64::scikit-learn-0.22.1-py37h27c97d8_0
    defaults/osx-64::tensorflow-base-2.0.0-mkl_py37h66b1bf0_0
    defaults/osx-64::tensorflow-2.0.0-mkl_py37hda344b4_0

这时候等待即可。
注意上面吧的命令不要输错了,我当时输入成:
conda create -v -f tensorflow.yml
结果一直显示:

Traceback (most recent call last):
  File "/Users/leo/opt/miniconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1079, in __call__
    return func(*args, **kwargs)
  File "/Users/leo/opt/miniconda3/lib/python3.7/site-packages/conda/cli/main.py", line 84, in _main
    exit_code = do_call(args, p)
  File "/Users/leo/opt/miniconda3/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
    return getattr(module, func_name)(args, parser)
  File "/Users/leo/opt/miniconda3/lib/python3.7/site-packages/conda/cli/main_create.py", line 23, in execute
    raise CondaValueError("The target prefix is the base prefix. Aborting.")
conda.exceptions.CondaValueError: The target prefix is the base prefix. Aborting.

5、检查TensorFlow的命令行

terminal里依次输入:
conda activate tensorflow
python
import tensorflow as tf
print(tf.__version__)
输出结果应该为2.0.0

相关文章

网友评论

      本文标题:如何在Mac上安装TensorFlow

      本文链接:https://www.haomeiwen.com/subject/tavlyhtx.html