2022-02-06
我听说谷歌的第二代机器学习框架是开源的。我还突发奇想去探索的产品,然而,安装一整天都很麻烦。现在我已经把备忘录整理好了
官方网站上给出的安装步骤非常简单:
# Only CPU-version is available at the moment.
$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
安装pip
使用PIP工具。检查PIP中的yum。安装包非常方便
好的,然后安装一个pip。pip的安装方法也很简单,即需要先安装,然后再下载。PIP安装命令如下:
qyfmac$ tar zxvf pip-7.1.2.tar.gz
qyfmac$ cd pip-7.1.2
qyfmac$ python setup.py install
安装时间错误:
qyfmac$ python setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
error: can't create or remove files in install directory
![图片[1]-学习tensorflow之mac上安装tensorflow-唐朝资源网](https://images.43s.cn/wp-content/uploads//2022/06/1655201806779_1.jpg)
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-38643.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Python/2.7/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://pythonhosted.org/setuptools/easy_install.html
Please make the appropriate changes for your system and try again.
这意味着许可是不够的。我们添加sudo以继续
qyfmac$ sudo python setup.py install
安装后,执行命令pip列出已安装的,并验证是否安装了pip
qyfmac$ pip freeze
altgraph==0.10.2
bdist-mpkg==0.5.0
bonjour-py==0.3
macholib==1.5.1
matplotlib==1.3.1
modulegraph==0.10.4
numpy==1.10.1
py2app==0.7.3
...
列出了许多包。我唯一不明白的是当我加载了这么多包时
安装
现在是主角出现的时候了执行安装命令来安装
qyfmac$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl
悲剧仍在发生。鬼魂必须用梯子才能接近它。下载各种超时
黄天尽了最大努力。一个有爱心的男人已经发布并上传了百度云密码:sznb
下载并安装
qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whl
安装沙盒工具毕竟,我们正在自己的机器上做实验。为了不来回修改各种环境变量,我们通常最好在测试后制作一个沙盒,您可以直接删除它,而无需更改各种配置文件
使用PIP命令安装:
qyfmac$ sudo pip install --upgrade virtualenv
安装后创建一个工作目录,我直接在home中创建一个文件夹
qyfmac$ virtualenv --system-site-packages ~/tensorflow
![图片[2]-学习tensorflow之mac上安装tensorflow-唐朝资源网](https://images.43s.cn/wp-content/uploads//2022/06/1655201806779_4.png)
然后输入激活沙盒的目录
qyfmac$ cd ~/tensorflow
qyfmac$ source bin/activate
(tensorflow) qyfmac$
安装
下载的-0.5.0-py2-none-any将WHL文件放在~/目录中
进入沙盒后,执行命令在沙盒中安装
(tensorflow) qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whl
运行
我在运行时,它以相同的方式直接在系统中实现
根据官方文件
(tensorflow) qyfmac$ python
Python 2.7.10 (default, Aug 22 2015, 20:33:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
![图片[3]-学习tensorflow之mac上安装tensorflow-唐朝资源网](https://images.43s.cn/wp-content/uploads//2022/06/1655201806779_5.png)
>>> hello = tf.constant('Hello,TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>>
敲打see=tf()此行将报告一个错误
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 4
can't determine number of CPU cores: assuming 4
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4
您可以先忽略它,并且不会影响最终的执行结果
参考文献
pdf文件下载:
关于作者
分类:
技术要点:
相关文章:
© 版权声明
本站下载的源码均来自公开网络收集转发二次开发而来,
若侵犯了您的合法权益,请来信通知我们1413333033@qq.com,
我们会及时删除,给您带来的不便,我们深表歉意。
下载用户仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,访问及下载者下载默认同意本站声明的免责申明,请合理使用切勿商用。
THE END
暂无评论内容