K80服务器安装tensorflow

来源:互联网 发布:知源中学 编辑:程序博客网 时间:2024/05/29 18:21
一、文章来由

caffe处理多标签数据不够方便,转投tf。

dgx服务器自带tf docker,但是经常没有gpu用,还是需要自己装环境


二、开始

搭环境真心是个麻烦活,因为实验室服务器 permission 控制很死。。。。。。。(表示很奇葩),所以官网正常的安装方法都很难使用

首先我尝试了 install from sources,但是要先装 bazel,已经装上了有需要升级,就暂时放弃了


改用 virtual env,详见 https://www.tensorflow.org/install/install_linux#next_steps

但是ImportError: libcudnn.so.6,因为这个cudnn库没有在 /usr/local/cuda/include 和 /usr/local/cuda/lib64里面,但是有需要权限,于是用 export一下就可以了

LD_LIBRARY_PATH


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hwang/hwang/tools/cuda/lib64

Installing with virtualenv

Take the following steps to install TensorFlow with Virtualenv:

  1. Install pip and virtualenv by issuing one of the following commands:

    $ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7 $ sudo apt-get install python3-pip python3-dev python-virtualenv # for Python 3.n

  2. Create a virtualenv environment by issuing one of the following commands:

    $ virtualenv --system-site-packages targetDirectory # for Python 2.7 $ virtualenv --system-site-packages -p python3 targetDirectory # for Python 3.n

    where targetDirectory specifies the top of the virtualenv tree. Our instructions assume thattargetDirectory is ~/tensorflow, but you may choose any directory.

  3. Activate the virtualenv environment by issuing one of the following commands:

    $ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh $ source ~/tensorflow/bin/activate.csh # csh or tcsh

    The preceding source command should change your prompt to the following:

    (tensorflow)$

  4. Ensure pip ≥8.1 is installed:

    (tensorflow)$ easy_install -U pip

  5. Issue one of the following commands to install TensorFlow in the active virtualenv environment:

    (tensorflow)$ pip install --upgrade tensorflow # for Python 2.7 (tensorflow)$ pip3 install --upgrade tensorflow # for Python 3.n (tensorflow)$ pip install --upgrade tensorflow-gpu # for Python 2.7 and GPU (tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU

    If the preceding command succeeds, skip Step 6. If the preceding command fails, perform Step 6.

  6. (Optional) If Step 5 failed (typically because you invoked a pip version lower than 8.1), install TensorFlow in the active virtualenv environment by issuing a command of the following format:

    (tensorflow)$ pip install --upgrade tfBinaryURL # Python 2.7 (tensorflow)$ pip3 install --upgrade tfBinaryURL # Python 3.n

    where tfBinaryURL identifies the URL of the TensorFlow Python package. The appropriate value of tfBinaryURLdepends on the operating system, Python version, and GPU support. Find the appropriate value for tfBinaryURL for your system here. For example, if you are installing TensorFlow for Linux, Python 3.4, and CPU-only support, issue the following command to install TensorFlow in the active virtualenv environment:

    (tensorflow)$ pip3 install --upgrade \ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp34-cp34m-linux_x86_64.whl

If you encounter installation problems, see Common Installation Problems.

Next Steps

After installing TensorFlow, validate the installation.

Note that you must activate the virtualenv environment each time you use TensorFlow. If the virtualenv environment is not currently active, invoke one of the following commands:

$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh$ source ~/tensorflow/bin/activate.csh # csh or tcsh

When the virtualenv environment is active, you may run TensorFlow programs from this shell. Your prompt will become the following to indicate that your tensorflow environment is active:

(tensorflow)$

When you are done using TensorFlow, you may deactivate the environment by invoking the deactivate function as follows:

(tensorflow)$ deactivate

The prompt will revert back to your default prompt (as defined by the PS1 environment variable).

Uninstalling TensorFlow

To uninstall TensorFlow, simply remove the tree you created. For example:

$ rm -r targetDirectory