在Linux上安装tensorflow

时间:2016-03-04 01:21:59

标签: tensorflow

我正在尝试在Linux上安装Tensorflow。不幸的是,我几乎无法使用Ubuntu。

我按照了" https://www.tensorflow.org/versions/master/get_started/os_setup.html#create-the-pip-package-and-install"

我被困在"创建pip包并安装"部分。 当我输入" bazel build -c opt //tensorflow/tools/pip_package:build_pip_package"终端给我下面

No command 'bazel' found, did you mean:
 Command 'babel' from package 'openbabel' (universe)
 Command 'babel' from package 'babel-1.4.0' (universe)
bazel: command not found

它有什么问题?

6 个答案:

答案 0 :(得分:8)

您需要安装" Bazel",google的本土构建工具来构建源代码。你可以在这里得到它:Installing Bazel

但是如果你刚刚开始使用它,你甚至需要费心从源代码构建?

也许你应该尝试使用pip和一行命令安装二进制文件,如下所述:pip installation

# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade   https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl

答案 1 :(得分:5)

我遇到过类似的问题。然后我意识到我忘了按如下方式设置环境:

export PATH="$PATH:$HOME/bin"

答案 2 :(得分:1)

I wrote a small bash script that sets up Ubuntu to be ready to run TensorFlow. It may be of use to you:

https://github.com/jasonmayes/Tensor-Flow-on-Google-Compute-Engine

From the script here you can see how I install bazel, however that also has a number of dependencies :-)

wget https://github.com/bazelbuild/bazel/releases/download/0.1.5/bazel-0.1.5-installer-linux-x86_64.sh -O bazel-0.1.5-installer-linux-x86_64.sh
chmod +x bazel-0.1.5-installer-linux-x86_64.sh
sudo ./bazel-0.1.5-installer-linux-x86_64.sh --user
rm bazel-0.1.5-installer-linux-x86_64.sh
sudo chown $USER:$USER ~/.cache/bazel/

答案 3 :(得分:0)

您可以直接从“pip install”安装tensorflow,也可以从源代码安装。如果您选择从源代码安装。首先你应该安装bazel,它是一个从源代码构建tensorflow的工具。

答案 4 :(得分:0)

只是更新:

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only, Python 2.7:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.4
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.5
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
# Requires CUDA toolkit 7.5 and CuDNN v4. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl

# Mac OS X, CPU only, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py3-none-any.whl
Install TensorFlow:

# Python 2
$ sudo pip install --upgrade $TF_BINARY_URL

# Python 3
$ sudo pip3 install --upgrade $TF_BINARY_URL

更多细节:

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md

答案 5 :(得分:0)

如果你的系统安装了pip,这是一项简单的任务。如果没有,请使用以下命令安装pip:

sudo apt-get install python-pip python-dev

您可以使用系统GPU或CPU运行Tensorflow。另请注意,截至目前,tensorflow仅支持Nvidia GPU。如果你有一个Nvidia GPU,reading this link会更好,因为它提供了很好的清晰度。

对于CPU安装运行 -

  1. export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl

    这将设置二进制文件所在的URL。它会不时变化,因此请确保使用适当的URL。接下来,运行 -

  2. sudo pip install --upgrade $TF_BINARY_URL