Install TensorFlow in virtualenv mode on Ubuntu

Source: Internet
Author: User
Tags virtualenv

Install TensorFlow in virtualenv mode on Ubuntu

This article describes how to install tensorflow in virtualenv mode on Ubuntu.

Install pip and virtualenv:

# Ubuntu/Linux 64-bit

Sudo apt-get install python-pip python-dev python-virtualenv

# Mac OS X

Sudo easy_install pip

Sudo pip install -- upgrade virtualenv

Create a Virtualenv virtual environment:

Go to the parent directory where you want to install tensorflow and run the following command to create a virtual environment:

Virtualenv -- system-site-packages tensorflow

Activate the virtual environment and install tensorflow:

For python27, run the following command:

Source./tensorflow/bin/activate # If using bash

Source./tensorflow/bin/activate. csh # If using csh

(Tensorflow) $ # Your prompt shocould change

# Ubuntu/Linux 64-bit, CPU only:

Pip install -- upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled:

Pip install -- upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only:

Pip install -- upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py2-none-any.whl

For python3, run the following command:

Source./tensorflow/bin/activate # If using bash

Source./tensorflow/bin/activate. csh # If using csh

(Tensorflow) $ # Your prompt shocould change

# Ubuntu/Linux 64-bit, CPU only:

Pip install -- upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp34-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled:

Pip install -- upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.6.0-cp34-none-linux_x86_64.whl

# Mac OS X, CPU only:

Pip3 install -- upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl

Test and install:

Run the following command on the terminal to enter the python shell environment:

Python

Test in the python shell environment:

>>> Import tensorflow as tf

>>> Hello = tf. constant ('hello, TensorFlow! ')

>>> Sess = tf. Session ()

>>> Print (sess. run (hello ))

Hello, TensorFlow!

>>> A = tf. constant (10)

>>> B = tf. constant (32)

>>> Print (sess. run (a + B ))

42

>>>

• If the following error occurs:

1

2

_ Mod = imp. load_module ('_ pywrap_tensorflow', fp, pathname, description)

ImportError: libcudart. so.7.0: cannot open shared object file: No such file or directory

That is, your CUDA installation configuration is incorrect:

For more information about installing CUDA and CUDNN, see this article.

Add the following two rows to your ~ /. Bashrc File

Export LD_LIBRARY_PATH = "$ LD_LIBRARY_PATH:/usr/local/cuda/lib64"

Export CUDA_HOME =/usr/local/cuda

• If the following error occurs:

Python 2.7.9 (default, Apr 2 2015, 15:33:21)

[GCC 4.9.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> Import tensorflow

I tensorflow/stream_executor/dso_loader.cc: 93] Couldn't open CUDA library libcublas. so.7.0.ld_library_path:/usr/local/cuda/lib64

I tensorflow/stream_executor/cuda/cuda_blas.cc: 2188] Unable to load cuBLAS DSO.

I tensorflow/stream_executor/dso_loader.cc: 93] Couldn't open CUDA library libcudnn. so.6.5. LD_LIBRARY_PATH:/usr/local/cuda/lib64

I tensorflow/stream_executor/cuda/cuda_dnn.cc: 1382] Unable to load cuDNN DSO

I tensorflow/stream_executor/dso_loader.cc: 93] Couldn't open CUDA library libcufft. so.7.0.ld_library_path:/usr/local/cuda/lib64

I tensorflow/stream_executor/cuda/cuda_fft.cc: 343] Unable to load cuFFT DSO.

I tensorflow/stream_executor/dso_loader.cc: 101] successfully opened CUDA library libcuda. so locally

I tensorflow/stream_executor/dso_loader.cc: 93] Couldn't open CUDA library libcurand. so.7.0.ld_library_path:/usr/local/cuda/lib64

I tensorflow/stream_executor/cuda/cuda_rng.cc: 333] Unable to load cuRAND DSO.

According to the installation error, we can see that it uses version 7.0, so it cannot be found. If you install version 7.5, you can run the following command to add the corresponding link:

Sudo ln-s/usr/local/cuda/lib64/libcudart. so.7.5/usr/local/cuda/lib64/libcudart. so.7.0

Sudo ln-s libcublas. so.7.5 libcublas. so.7.0

Sudo ln-s libcudnn. so.4.0.4 libcudnn. so.6.5

Sudo ln-s libcufft. so libcufft. so.7.0 <br> sudo ln-s libcurand. so libcurand. so.7.0

Install TensorFlow source code in Ubuntu 15.04

How to evaluate Tensorflow and other deep learning systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.