TensorFlow installation of virtualenv mounting method

Source: Internet
Author: User
Tags virtualenv

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

Install Pip and virtualenv:
# ubuntu/linux 64-bitsudo apt-get install python-pip python-dev python-virtualenv# Mac OS xsudo easy_install pipsudo pip I Nstall--upgrade virtualenv
To create a virtualenv virtual environment:

Enter the parent directory where you want to install TensorFlow, and then execute the following command to establish the virtual environment:

Virtualenv--system-site-packages TensorFlow
To activate the virtual environment and install TensorFlow:

For Python27, execute the following command:

source./tensorflow/bin/activate  # If using Bashsource./tensorflow/bin/activate.csh  # If using CSH (TensorFlow ) $  # Your prompt should change# ubuntu/linux 64-bit, CPU only:pip install--upgrade https://storage.googleapis.com/te nsorflow/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, execute the following command:

source./tensorflow/bin/activate  # If using Bashsource./tensorflow/bin/activate.csh  # If using CSH (TensorFlow ) $  # Your prompt should change# ubuntu/linux 64-bit, CPU only:pip install--upgrade https://storage.googleapis.com/te nsorflow/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 installation:

Execute the following command at 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 (ten) >>> B = Tf.constant (+) >>> print (Sess.run (A + b)) 42>>>
    • If you encounter the following error:
    _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's your cuda. The installation configuration is incorrect:

The installation of Cuda and CUDNN can be consulted in this article.

and add the following two lines to your ~/.BASHRC file

Export ld_library_path= "$LD _library_path:/usr/local/cuda/lib64" Export Cuda_home=/usr/local/cuda
    • If you encounter the following error:
Python 2.7.9 (Default, APR 2, 15:33:21) [GCC 4.9.2] on Linux2type ' help ', ' copyright ', ' credits ' or ' license ' for MO Re information.>>> import tensorflowi tensorflow/stream_executor/dso_loader.cc:93] Couldn ' t open CUDA Library libcublas.so.7.0. Ld_library_path::/usr/local/cuda/lib64i 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/lib64i tensorflow/stream_executor/cuda/cuda_dnn.cc:1382] Unable to load CuDNN DSOI TENSORFLOW/STREAM_EXECUTOR/DSO_LOADER.CC:93] couldn ' t open CUDA Library libcufft.so.7.0. Ld_library_path::/usr/local/cuda/lib64i 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 Locallyi Tensorflow/stream _EXECUTOR/DSO_LOADER.CC:93] couldn ' t open CUDA Library libcurand.so.7.0. Ld_library_path::/USr/local/cuda/lib64i tensorflow/stream_executor/cuda/cuda_rng.cc:333] Unable to load Curand DSO. 

The installation error indicates that it is using the 7.0 version, it is not found, and if you install the 7.5 version, you can do the following command to add the appropriate link:

sudo ln-s/usr/local/cuda/lib64/libcudart.so.7.5/usr/local/cuda/lib64/libcudart.so.7.0sudo ln-s libcublas.so.7.5 Libcublas.so.7.0sudo ln-s libcudnn.so.4.0.4 libcudnn.so.6.5sudo ln-s libcufft.so libcufft.so.7.0
sudo ln-s libcurand.so libcurand.so.7.0

TensorFlow installation of virtualenv mounting method

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.