1. 程式人生 > >原始碼安裝tensorflow

原始碼安裝tensorflow

下載tensorflow:

安裝python依賴庫:

sudo apt-get install python-numpy python-dev python-pip python-wheel 如果是安裝tensorflow for python3,則為:

sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel 要實現GPU計算,還需要安裝cuda,cudnn,安裝步驟可參考:http://blog.csdn.net/u011961856/article/details/76723285

安裝libcupti-dev:

sudo apt-get install libcupti-dev 安裝bazel:

進入tensorflow目錄

cd tensorflow

執行configure:

./configure

編譯pip 安裝包:

cpu:

sudo bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package gpu

sudo bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package 生成pip安裝包,.whl檔案:

sudo bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg 進入目錄/tmp/tensorflow_pkg,並檢視生成的.whl檔案:

貸超APP開發找上海捌躍網路科技有限公司QQ3343874032 cd /tmp/tensorflow_pkg ls

查詢發現生成的安裝包名為:

tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl

pip安裝tensorflow for python2:

sudo pip2 install tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl pip安裝tensorflow for python3:

sudo pip3 install tensorflow-1.3.0rc1-cp27-cp27mu-linux_x86_64.whl

測試是否安裝成功:

import tensorflow成功,說明安裝成功.