Install TensorFlow GPU for Windows


Before installing tensorflow, install CUDA 8.0 and Cudnn 5.1 first.

CUDA 7.5 is not compatible!  https://github.com/tensorflow/tensorflow/issues/9469

Uninstall 7.5  and reboot  if you have it previously installed.

Install TensorFlow as official guide

Download and install anaconda, in prompt

conda create --name tensorflow python=3.5
activate tensorflow
conda create --name tf python=3.6
activate tf 
(tensorflow)C:>conda install anaconda tensorflow-gpu

For old versions:

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0rc1-cp35-cp35m-win_amd64.whl

conda and pip are two separate package management tools. However, for some unknown reasons, install tensorflow using pip will not let virtual environment find how to initiate tensorflow, resulting following errors.

(tensorflow)C:>pip install --ignore-installed --upgrade tensorflow-gpu
python
import tensorflow
ImportError: No module named pywrap_tensorflow_internal
Failed to load the native TensorFlow runtime.

So we need to install tensorflow using conda install. 

conda install tensorflow-gpu

However, when you install tensorflow using pip, the files under Lib/site-packages will not be replaced by the conda installed tensorflow. By installing this second tensorflow is only letting virtual environment realize the existence of a package called tensorflow-gpu

For using Anaconda3 (or Miniconda3) you need to install nb_conda into the conda environment (in addition to jupyter):

conda install nb_conda jupyter

Then starting jupyter applications, for example

jupyter notebook

If there is an error about zmq package

pip uninstall pyzmq 
pip install pyzmq

even though there is a warning.

To add new ipykernel into jupyter

C:\Users\Li\AppData\Local\conda\conda\envs\tf\python.exe -m ipykernel install --prefix=C:\Users\Li\AppData\Local\conda\conda\envs\tf --name tf
D:\LiChen\Anaconda\envs\tf\python -m ipykernel install --user --name tf

To list all conda envs

conda env list

If you want to delete  conda environment

conda remove --name tf --all

To test tensoflow installed correctly

import tensorflow as tf
#check which version is actually working
print(tf.__version__)
#1.3.0
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))


To change jupyter default path, edit the jupyter notebook config file. 

jupyter notebook --generate-config

This writes a file to C:\Users\username\.jupyter\jupyter_notebook_config

Change line 179 #c.NotebookApp.notebook_dir = ''

to c.NotebookApp.notebook_dir = 'your path'

Make sure you use forward slashes in your path.


list all kernels in jupyter

jupyter-kernelspec list

If the "tensorflow" environment is not shown in jupyter notebook

Install kernels

python -m ipykernel install --user

veryfy the install

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

Optionally, other useful modules to install

pip install keras matplotlib scikit-image tifffile sklearn opencv-python pydicom imageio interpolation mysql-connector SimpleITK medpy
pip install git+https://www.github.com/farizrahman4u/keras-contrib.git
#python server
pip install h5py flask


Last Article

Comment 评论



Share 分享

New Users 最新加入

  • hokurikustr

  • refrain

New comments 最新评论

test123: aasdas Details Apr 13 16:39
admin: Thanks! Details Apr 09 11:46
admin: Google map api Details Apr 09 11:46
lqj12: cooooooooool Details Apr 08 21:34
Yunhan Huang: 这个功能是如何实现的? Details Apr 08 13:23