Tensorflow安装步骤
来源:互联网 发布:易观智库数据 编辑:程序博客网 时间:2024/06/03 14:59
本文主要包括如下几个部分:
- docker 安装
- pip安装
- 编译安装
- 问题
- 参考文献
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 会看到如下的内容,里面包含密码。访问http://localhost:8888即可进入Jupyter编辑器。6066为TensorBoard。
[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.whlMac OS X # 当前版本只支持 CPU$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whlDocker$ docker run -it b.gcr.io/tensorflow/tensorflow
3. 编译安装
不推荐
4. 问题
使用pip安装基本没有什么问题,但是需要注意的是。千万不要使用Mac自带的python,那个地方是写保护的。
报错信息如下:
sh-3.2# pip install --upgrade $TF_BINARY_URLCollecting 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/sCollecting mock>=2.0.0 (from tensorflow==0.12.0) Downloading mock-2.0.0-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 229kB/sCollecting 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/sCollecting protobuf==3.1.0 (from tensorflow==0.12.0) Downloading protobuf-3.1.0-py2.py3-none-any.whl (339kB) 100% |████████████████████████████████| 348kB 346kB/sRequirement 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.whlCollecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow==0.12.0) Downloading funcsigs-1.0.2-py2.py3-none-any.whlCollecting 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/sCollecting setuptools (from protobuf==3.1.0->tensorflow==0.12.0) Downloading setuptools-36.0.1-py2.py3-none-any.whl (476kB) 100% |████████████████████████████████| 481kB 337kB/sInstalling 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即可。
参考文献
[1] TensorFlow 官方教程
阅读全文
1 0
- tensorflow安装步骤
- Tensorflow安装步骤
- Windows安装Tensorflow步骤
- TensorFlow安装步骤记录
- Windows下安装tensorflow步骤
- windos10安装TensorFlow详细步骤。
- centos7 安装tensorflow 环境步骤
- Windows下安装Tensorflow步骤
- windows下tensorflow安装步骤
- 64位win10上安装TensorFlow步骤
- Windows 7下安装TensorFlow步骤
- Windows下安装tensorflow步骤--更ok
- MacOS安装anaconda以及Tensorflow步骤
- ubuntu16.04安装TensorFlow的正确步骤
- TensorFlow在Windows 7上的详细安装步骤
- TensorFlow在Windows 7上的详细安装步骤
- Windows 7 64位安装TenSorFlow详细步骤
- Windows Tensorflow CPU版安装的几个关键步骤
- Cannot acquire a lock,资料贴,仅供参考
- Unity Learning for Coroutine(协程)
- opencl环境搭建(更新版)
- PAT练习-科学计数法
- java:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。
- Tensorflow安装步骤
- 带宽与延时知识整理
- 数组、ArrayList、List、LinkedList的区别
- iOS 颜色渐变
- C# 使用 MonoPInvokeCallback,让 C 直接回调 C# 函数(C/C++ 跨平台方案)
- linux 安装 git
- sdl2.0 线程
- c语言简单的数据结构动态链表
- 从Inception v1,v2,v3,v4,RexNeXt到Xception再到MobileNets,ShuffleNet