频道栏目
首页 > 资讯 > 其他综合 > 正文

Tensorflow安装步骤

17-06-27        来源:[db:作者]  
收藏   我要投稿

 

1. docker安装

下载官方的镜像,即可使用。不过不推荐,因为这个Tensorflow的模块是在Docker内的,也就是你编译的时候,需要进入Docker镜像的内部进行使用。也就是import tensorflow as tf命令在你的Docker外是无法生效的。使用IDEA这样的调试工具调试的时候,会略微有点蛋疼。

但是,学习Tensorflow语法的话可以使用相对应的Jyter这个工具平台进行学习,非常方便。

分享一个很好的TensorFlow的Docker镜像和Docker仓库:

github 项目: https://github.com/caicloud/tensorflow-tutorial docker 仓库 docker pull cargo.caicloud.io/tensorflow/tensorflow:0.12.0 启动 docker run - it cargo.caicloud.io/tensorflow/tensorflow:0.12.0 -p 8888:8888 -p 6066:6066 8888为Jupyter编辑器,docker logs 会看到如下的内容,里面包含密码。
[root@rhel6 ~]# docker logs 45fd0affc965
[I 03:19:24.125 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 03:19:24.246 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 03:19:24.337 NotebookApp] Serving notebooks from local directory: /notebooks
[I 03:19:24.337 NotebookApp] 0 active kernels
[I 03:19:24.337 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=a05b41be2597511483fb59beb86a4bb88fe02fe51bf6ed54
[I 03:19:24.339 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Starting TensorBoard 39 on port 6006

2. pip安装

使用pip前,先确定安装了python。
在命令行输入python/python3,即可判断你是否全局配置了python程序。

MAC OSX系统不推荐使用官方自带的Python2.7.3程序,因为那边有很多的程序是被写保护的。

Ubuntu/Linux 

# 仅使用 CPU 的版本
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

# 开启 GPU 支持的版本 (安装该版本的前提是已经安装了 CUDA sdk)
$ pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

Mac OS X 

# 当前版本只支持 CPU
$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

Docker

$ docker run -it b.gcr.io/tensorflow/tensorflow

3. 编译安装

不推荐

4. 问题

使用pip安装基本没有什么问题,但是需要注意的是。千万不要使用Mac自带的python,那个地方是写保护的。

报错信息如下:

sh-3.2# pip install --upgrade $TF_BINARY_URL
Collecting tensorflow==0.12.0 from https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py2-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py2-none-any.whl (38.8MB)
    100% |████████████████████████████████| 38.8MB 24kB/s
Collecting mock>=2.0.0 (from tensorflow==0.12.0)
  Downloading mock-2.0.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 229kB/s
Collecting numpy>=1.11.0 (from tensorflow==0.12.0)
  Downloading numpy-1.13.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.6MB)
    100% |████████████████████████████████| 4.6MB 159kB/s
Collecting protobuf==3.1.0 (from tensorflow==0.12.0)
  Downloading protobuf-3.1.0-py2.py3-none-any.whl (339kB)
    100% |████████████████████████████████| 348kB 346kB/s
Requirement already up-to-date: wheel in /Library/Python/2.7/site-packages (from tensorflow==0.12.0)
Collecting six>=1.10.0 (from tensorflow==0.12.0)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow==0.12.0)
  Downloading funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow==0.12.0)
  Downloading pbr-3.0.1-py2.py3-none-any.whl (99kB)
    100% |████████████████████████████████| 102kB 404kB/s
Collecting setuptools (from protobuf==3.1.0->tensorflow==0.12.0)
  Downloading setuptools-36.0.1-py2.py3-none-any.whl (476kB)
    100% |████████████████████████████████| 481kB 337kB/s
Installing collected packages: six, funcsigs, pbr, mock, numpy, setuptools, protobuf, tensorflow
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-lNI6hy-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

解决办法: brew install python,使用新的python即可。

相关TAG标签
上一篇:utf8 utf-8 gbk gb2312的区别
下一篇:[翻译]Kafka Streams简介: 让流处理变得更简单
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站