AI(人工智能) TensorFlow 源码下载及编译安装

xiaoxiao2021-02-27  283

源码下载:

git clone https://github.com/tensorflow/tensorflow cd tensorflow git checkout r1.1

切换1.1版本的代码

编译环境配置(Ubuntu14.04)

1.python : a. python 的版本是2.7 的话,如下安装:sudo apt-get install python-numpy python-dev python-pip python-wheelb. python 的版本是3.X的话,如下安装:sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel2.python依赖: sudo pip install six numpy wheel3.bazel 安装: https://github.com/bazelbuild/bazel/releases 直接下载bazel-0.4.5-installer-linux-x86_64.sh脚本,然后到下载目录执行 ./bazel-0.4.5-installer-linux-x86_64.sh即可

编译安装

进入源码目录,先执行配置文件

$ ./configure Please specify the location of python. [Default is /usr/bin/python]: Please specify optimization flags to use during compilation when bazel option “–config=opt” is specified [Default is -march=native]: Do you wish to use jemalloc as the malloc implementation? [Y/n] y jemalloc enabled Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n No Google Cloud Platform support will be enabled for TensorFlow Do you wish to build TensorFlow with Hadoop File System support? [y/N] n No Hadoop File System support will be enabled for TensorFlow Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] n No XLA JIT support will be enabled for TensorFlow Found possible Python library paths: /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]

Using python library path: /usr/local/lib/python2.7/dist-packages Do you wish to build TensorFlow with OpenCL support? [y/N] n No OpenCL support will be enabled for TensorFlow Do you wish to build TensorFlow with CUDA support? [y/N] n No CUDA support will be enabled for TensorFlow Configuration finished …….. INFO: Starting clean (this may take a while). Consider using –expunge_async if the clean takes more than several minutes. …….. INFO: All external dependencies fetched successfully.

配置完之后执行如下命令编译安装

bazel build –config=opt //tensorflow/tools/pip_package:build_pip_package bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0rc0-cp27-none-linux_x86_64.whl

测试

不要在源码目录,随便找一个其他目录,执行python

$python

输入如下代码:

import tensorflow as tf hello = tf.constant(‘Hello, TensorFlow!’) sess = tf.Session() print(sess.run(hello))

终端打印如下语句:

Hello, TensorFlow!

perfect, 搭建完毕,现在可以开始编程了,万里长征迈出了第一步,加油!

转载请注明原文地址: https://www.6miu.com/read-3467.html

最新回复(0)