Step 8: Go to terminal and type:
nano ~/.bashrc
In the end of the file, add:
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
ctrl+x then y to save and exit
source ~/.bashrc sudo ldconfig nvidia-smi
Check driver version.
(not likely) If you got nvidia-smi is not found then you have unsupported linux kernel installed. Comment your linux kernel version noted in step 5.
Step 9: Install cuDNN 7.1.2:
Goto this link and download the required files. (Membership required)
After login
Download the following:
cuDNN v7.1.2 Runtime Library for Ubuntu16.04 (Deb)
cuDNN v7.1.2 Developer Library for Ubuntu16.04 (Deb)
cuDNN v7.1.2 Code Samples and User Guide for Ubuntu16.04 (Deb)
Goto downloaded folder and in terminal perform following:
sudo dpkg -i libcudnn7_7.1.2.21-1+cuda9.1_amd64.deb sudo dpkg -i libcudnn7-dev_7.1.2.21-1+cuda9.1_amd64.deb sudo dpkg -i libcudnn7-doc_7.1.2.21-1+cuda9.1_amd64.deb
Verifying cuDNN installation:
cp -r /usr/src/cudnn_samples_v7/ $HOME cd $HOME/cudnn_samples_v7/mnistCUDNN make clean && make ./mnistCUDNN
If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:
Test passed!
Step 10: Install Dependencies
libcupti (required)
sudo apt-get install libcupti-dev echo 'export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc sudo ldconfig
Step11: Download whl file
Goto https://pypi.python.org/pypi/tensorflow-gpu and download whl package related to your python version and os.
For eg., if your python version is 3.5 and os is linux then select
tensorflow_gpu-1.7.0-cp35-cp35m-manylinux1_x86_64.whl
Step 12: Install whl file
Create a new virtual environment and activate it then install the whl file using the command.
for python 2:
pip2 install [whl file path]
for python 3:
pip3 install [whl file path]
Step 13: Verify Tensorflow installation
Verify tensorflow using following commands:
$ python >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> sess.run(hello) 'Hello, TensorFlow!' >>> a = tf.constant(10) >>> b = tf.constant(32) >>> sess.run(a + b) 42 >>> sess.close()
Note:- It may take some time after tf.Session() for first time.
This is all you need to do to install tensorflow GPU version on Ubuntu 16.04.
For Windows-64bit OS:
Install CPU Version of Tensorflow:
I have already mentioned the condition in which CPU version of tensorflow is preferable to the GPU version earlier in the post. Let’s get right to how to install tensorflow CPU version for windows OS.
Step1: Download whl file
Goto https://pypi.python.org/pypi/tensorflow and download whl package related to your python version and os.
For eg., if your python version is 3.5 and os is Windows then select
tensorflow-1.7.0-cp35-cp35m-win_amd64.whl
Step 2: Install whl file
Create a new virtual environment and activate it then install the whl file using the command.
for python 2:
pip2 install [whl file path]
for python 3:
pip3 install [whl file path]
Step 3: Verify tensorflow installation
Verify tensorflow is properly installed using the following commands:
$ python >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> sess.run(hello) 'Hello, TensorFlow!' >>> a = tf.constant(10) >>> b = tf.constant(32) >>> sess.run(a + b) 42 >>> sess.close()
This is all you need to do to install tensorflow CPU version on Windows OS.
Install GPU Version of Tensorflow:
GPU tensorflow is recommended for intermediate to advanced users. For users who work with large dataset, the GPU version is almost a necessity as it can greatly speed up training time. Advanced users who want to build pip package to get optimum performance can follow the link at the top of the article to build tensorflow gpu for Windows.
Step 1: Verify you have a CUDA-Capable GPU:
Before doing anything else, you need to verify that you have a CUDA-Capable GPU in order to install tensorflow GPU. You can verify that you have a CUDA-capable GPU through the Display Adapters section in the Windows Device Manager. Here you will find the vendor name and model of your graphics card(s).
The Windows Device Manager can be opened via the following steps:
Open a run window from the Start Menu or (Win+R)
Run:
control /name Microsoft.DeviceManager
If your graphics card is from NVIDIA then go to http://developer.nvidia.com/cuda-gpus and verify if listed in CUDA enabled GPU list.
Step 2: Download the NVIDIA CUDA Toolkit:
Go to this link and download Installer for Windows > x86_64 > 10 > exe[network]
Uninstall Nvidia and Cuda related programs from Control Panel > Program and Features.
If a reboot is required, then reboot.
Install it in default location with default settings. It will update your GPU driver if required.
Step 3: Reboot the system to load the NVIDIA drivers.
Step 4: Install cuDNN 7.1.2:
Goto this link and download the necessary files. (Membership required)
After login, download the following:
cuDNN v7.1.2 Library for Windows [your version]. For me, it’s Windows 10
Goto downloaded folder and extract cudnn-9.0-windows[your version]-x64-v7.zip
Go inside extracted folder and copy all files and folder from cuda folder (eg. Bin, include, lib) and paste to “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0”.
Step 5: Download whl file
Goto https://pypi.python.org/pypi/tensorflow-gpu and download whl pacakage related to your python version and os.
For eg., if your python version is 3.5 and os is Windows then select
tensorflow_gpu-1.7.0-cp35-cp35m-win_amd64.whl
Step 6: Install whl file
Create a new virtual environment and activate it then install the whl file using the command.
for python 2:
pip2 install [whl file path]
for python 3:
pip3 install [whl file path]
Step 7: Verify tensorflow installation
Verify tensorflow using following commands:
$ python >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> sess.run(hello) 'Hello, TensorFlow!' >>> a = tf.constant(10) >>> b = tf.constant(32) >>> sess.run(a + b) 42 >>> sess.close()
Note:- It may take some time after tf.Session() for first time.
This is all you need to do to install tensorflow GPU version on Windows OS.
If you follow the steps mentioned above carefully, you will be able to install tensorflow both CPU and GPU version on Ubuntu as well as Windows OS. If you encounter any problem during the process, do let us know in the comments and we will help you.
I’m not a very experienced programmer or IT expert. I have installed Python 3.6 and I now try to install Tensorflow. When I try to install Tensorflow I get numerous error messages ‘Invalid Syntax’. I enter ‘pip3 install + the path to the tensorflow file’ . Please help!
There may be error due to wrong whl file. Use appropriate whl file according to your platform and python version and ensure that python is 64 bit. Also you can use
pip3 install --upgrade tensorflow
for cpu version andpip3 install --upgrade tensorflow-gpu
for gpu version.i have windows 7, i downloaded python 3.6.
which link should i install in step 1
You can use the whl with 36 and win. Simply use
pip install tensorflow
for cpu orpip install tensorflow-gpu
also works.Thanks for the marvelous posting! I seriously enjoyed reading it, you may be a great author.
I will make certain to bookmark your blog and will come back in the future.
I want to encourage you to continue your great job, have a nice weekend!
Hi,
First, thanks a lot for this tutorial, it helps a lot!
However I still got an error when checking the installation (Ubuntu 16.04 64bit) :
2018-02-10 14:52:51.176978: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1168] Ignoring visible gpu device (device: 0, name: GeForce GTX 760, pci bus id: 0000:01:00.0, compute capability: 3.0) with Cuda compute capability 3.0. The minimum required Cuda capability is 3.5.
And also something weird, the code ‘sess.run(hello)’ returns :
b’Hello, TensorFlow!’ (not sure where this ‘b’ comes from!)
If anyone already had the same pb and/or has an idea I’d be happy to hear your thoughts. Thanks!
You have old gpu and the b represents bytes type it is not a problem.
I have the same GPU (GTX-760) and compiled Tensorflow 1.5 from source on Ubuntu 16.04.
It’s really easy, just follow the steps: https://www.tensorflow.org/install/install_sources
Thank you. I can successfuly installed.
Hi.
I follow the step until 7, when I run “import tensorflow as tf” in python, i met:
”
ImportError: Could not find ‘cudart64_90.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit
”
I’m sure I installed cuda according the step 2/3/4.
Are there anything that I missed?
some info:
System: Windows 10
GPU: GTX 965M
cuda install exe: cuda_9.0.176.1_windows.exe
cudnn: cudnn-9.0-windows10-x64-v7
Python version: Python 3.6.4 :: Anaconda, Inc.
tensorflow wheel: tensorflow_gpu-1.6.0rc0-cp36-cp36m-win_amd64.whl
NVDIA program in “Programs and Features”:
1. NVDIA CUDA Development 9.0
2. NVDIA CUDA Runtime 9.0
3. NVDIA Image Drive Program 388.08
4. NVDIA update 29.1.0.0
Thank You!
Hello Liming, try tensorflow gpu 1.5.0 from this link https://pypi.python.org/pypi/tensorflow-gpu/1.5.0 and reply me the result.
Same problem…
I use “tensorflow_gpu-1.5.0-cp36-cp36m-win_amd64.whl”, when I run “import tensorflow as tf”, I met:
”
ImportError: Could not find ‘cudart64_90.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL: https://developer.nvidia.com/cuda-toolkit
“
More info:
I try to find “cudart64_90.dll” but can’t.
In the location “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin”, I only got three file: cublas64_90.dll, cudnn64_7.dll, nvblas64_90.dll.
I try to find similar program in Google. It’s seem that i installed cudnn9.0 failed? but I can find CUDA program in “Program and Features” as last comment….
I think re-installation of Cuda 9.0 should work. Uninstall All Nvidia and Cuda related programs from Control Panel > Program and Features. Try again ! And verify the files and its location in system environment.
The problem is that I have tried re-installation of Cuda 9.0 and I uninstall All these problem that hava “NVDIA” in its name before re-installation and I reboot after every step.=_=
Can you tell me if there is “cudart64_90.dll” file in your cudnn/bin or any dic in PATH?
More info 2:
I try to check my PATH variable:
only find:
1. “%SystemRoot%\system32”
2. “%SystemRoot%”
3. “%SystemRoot%\System32\Wbem”
4. “%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\”
5. “%SYSTEMROOT%\System32\LibreSSL\”
6. “%SYSTEMROOT%\System32\OpenSSH\”
I can’t find any dll about cudnn or cudart64_90.dll in these dic.
cudart64_90.dll exists in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin for me.
got it.
It’s because I use wrong installer for cuda= =
“cuda_9.0.176.1_windows.exe” isn’t right installer.
I downloaded “cuda_9.0.176_win10_network.exe” and it works good.
Now everything is Ok.
Thank you~~ O.O
Thanks for information. That’s why i always recommended network installation.
Thanks for this! It worked! I installed tensorflow-gpu but it didn’t connect to my two gpu cards, after a day of struggling I am happy I found this installation guide. It only worked for me when I installed using pip3!
I’m sorry forgot to mention I was installing on ubuntu 16.04 LTS
I am glad to hear that it worked for you. It is good to use virtual environment then directly installing to main python installation.
I follow the steps until 5.
I am using python3.6 on Windows10 cause people said TF1.5 support it, and I also see the download link for it.
but when I run pip install tensorflow_gpu-1.5.0-cp36-cp36m-win_amd64.whl
Error –>”tensorflow_gpu-1.5.0-cp36-cp36m-manylinux1_x86_64.whl is not a supported wheel on this platform.”
Are there anything that I missed?
You have downloaded linux version. Use windows version. ‘pip install tensorflow-gpu’ simply works. Also make sure pip belongs to python 3.6 by command ‘pip –version’. May be pip3 install [whl] should work. Use virtualenv if possible.
I download default python3.6 version which is 32bit. after correct the python version, everything works fine. Thank you at the same!
great !
Thank you!