Tensorflow-gpu, Cuda, CUDNN installation on Windows

Source: Internet
Author: User

Installation Instructions

Platform: Currently available on Ubuntu, Mac OS, Windows
Version: GPU version, CPU version available
Installation mode: PIP mode, Anaconda mode
Tips:

    1. Currently supports python3.5.x on Windows
    2. GPU version requires cuda8,cudnn5.1

Installation progress

2017/3/4 Progress:
Anaconda 4.3 (corresponding to python3.6) is being installed, deleted, nothing.
2017/3/5 Progress:
Anaconda 4.3 (corresponds to python3.6) get
Anaconda in Python3.5.2get
Tensorflow1.0.0get

Ideas

In the course of watching other people always encounter some of the nouns that have not seen, people are daunting.
So simply start with the noun explanation.
Then tell me about the installation and simple examples of tensorflow.
As a note of his own,
Also want to like me small white see this tutorial can feel to do very smooth!

CUDA

CUDA (Compute Unified Device Architecture), is the graphics card manufacturer Nvidia launched computing platform. CUDA? is a general-purpose parallel computing architecture introduced by NVIDIA that enables the GPU to solve complex computational problems. It includes the CUDA instruction set architecture (ISA) and the parallel computing engine inside the GPU. Developers can now use C language to write programs for Cuda architecture, and C is the most widely used high-level programming language. The program is written so that it can run at ultra high performance on a CUDA-capable processor. CUDA3.0 has started to support C + + and Fortran.
The computing industry is moving from "central processing", which uses only CPU, to "collaborative processing" used by CPUs and GPUs. To create this new model of computing, NVIDIA (NVIDIA) invented the programming model of CUDA (Compute Unified device Architecture, unified Computing device architecture) to take advantage of the advantages of CPU and GPU in the application. Now, the schema has been applied to GeForce (fine view), ION (Wing Yang), Quadro, and Tesla GPU (graphics processor).
From Baidu Encyclopedia.

(So my a card is not used for it.)

Anaconda

Anaconda is a leading Open data science platform powered by Python. The open source version of Anaconda is a high-performance distribution version of Python and R, including more than 100 of the most popular python,r and Scala packages for data science.
From Anaconda official download page
See Anaconda Official tutorial for details, easy to understand!

Anaconda Preliminary Study

0. Download Anaconda installation package: Anaconda official
I downloaded the anaconda4.3.0for Windows 64bit (built-in python3.6)
Download is ready to install, always next step.
1. Check if Anaconda is installed successfully:conda --version

(hehe, the first step succeeded, happy Point)
2. Detect which environments are currently installed:conda info --envs

(Only one!) Not afraid, keep coming! )
3. Check which versions of Python are currently available for installation:conda search --full-name python

(A lot more, which one?) Hehe, of course, is python3.5.
4. Install different versions of Python:conda create --name tensorflow python=3.5
(Guess the system will automatically select a 3.5.x version after entering the python=3.5 version)

(python3.5.3 do you want it?) Lab server is 3.5.2, unified good! )

(All right, go!.) )

Hee Hee It's OK! It's a step closer to success! )
5. Follow the prompts to activate:activate tensorflow

(hehe It has a small hat ~ to represent my current environment OH)
6. Ensure that the environment named TensorFlow has been successfully added:conda info --envs

(bravo!)
7. Check the Python version in the new environment:python --version

(^^ Happy ~)
8. Exit the current environment:deactivate

(The little hat fell off)
9. Switch the Environment:activate tensorflow

Which environment you want to switch to activate which one ~
Since this article is installed TensorFlow, of course, to Avtivate tensorflow!
You little goblin! I'm coming!

PS: Want to know more please see Anaconda Official tutorial, easy to understand and good to get started! Do not search the online tutorial, no official tutorials look refreshing!

TensorFlow Installation
This article is to install the TensorFlow on a native Windows system,
Using the Anocanda installation method,
The CPU version is installed (well, as AMD's graphics card, mask the face crying)

Anaconda 4.3.0.1 (with python3.6)
With python3.5.2 in Anaconda.
Here is the protagonist of today! Crackling

1. According to the official website instructions:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl


(OK, first wrong, then again!) I don't know what to do. (ㄒoㄒ)/~~)
2. Another attempt:pip install tensorflow


(The point is, the original is this!) I am AMD's card, the corresponding is not the same! )
3. Confirm that the TensorFlow installation was successful:
Error attempt: Type Python directly inside cmd, and then typeimport tensorflow as tf


(The young man is the default is python3.6 ah ah ah ah, to go from the anaconda into just installed that python3.5 inside Oh! ~

Correct try: Enter Anaconda Prompt-python inside, enter the installation of the name TensorFlow environment (we installed the python3.5.2 remember? ~), type Python, and then type import tensorflow as tf
Here you can find Anaconda Prompt-python:

Open Anaconda Navigator (Start menu->anaconda 3->anaconda Navigator), make a Spyder play, click "Install" under the Spyder, install it and become "Launch", Click on it to go in.

Say hello! to TensorFlow in the Spyder.

Output:

(Hehe hey hahaha I feel like I've succeeded!!!) What about you? ~ ~)

Refer to TensorFlow official documents, please visit the English website, the Chinese community does not seem to update the installation on Windows

TensorFlow routines to get started

Put a new thing together, let's use it first!
Concept of what to run after the first small program to look again!
Find a sense of accomplishment before you go on!
Example Source: Minist for ML Beginners

Minst Data set:

    1. 55000 training Set, 10000 test set, 5000 authentication set
    2. Every picture is 28pixels*28pixels

Code:

#获得数据集from TensorFlow. examples. Tutorials. mnist Import input_datamnist = Input_data. Read_data_sets ("mnist_data/", one_hot=true) import TensorFlow as TF#输入图像数据占位符x = TF. Placeholder (TF. float32, [None,784])#权值和偏差W = TF. Variable (TF. Zeros ([784,]) B = tf. Variable (TF. Zeros ([10]))#使用softmax模型y = tf. nn. Softmax (TF. Matmul (X, W) + b)#代价函数占位符y_ = TF. Placeholder (TF. float32, [None,10])#交叉熵评估代价cross_entropy = TF. Reduce_mean (-TF. Reduce_sum (Y_ * TF. log (Y), reduction_indices=[1]))#使用梯度下降算法优化: The learning rate is 0.5train_step = TF. Train. Gradientdescentoptimizer (0.5). Minimize (Cross_entropy)#Sessionsess = TF. InteractiveSession ()#初始化变量tf. Global_variables_initializer (). Run ()#训练模型, Training 1000 times for _In range (+): batch_xs, Batch_ys = mnist. Train. Next_batch (100) sess.run (train_step, Feed_dict={x:batch_xs, Y_: Batch_ys})  #计算正确率correct_prediction = Tf.equal (Tf.argmax (y,1), Tf.argmax (Y_,1)) accuracy = Tf.reduce_mean (Tf.cast (correct_prediction, Tf.float32)) print (Sess.run (accuracy, Feed_dict={x:mnist.test.images, Y_: mnist< Span class= "Hljs-preprocessor" >.test.labels}))     

Run Result: Output shows the accuracy of the model

Conclusion

Yesterday, it took most of the day to deploy the environment, not only to get nothing and make a mess. Fight today, simply do while writing, as if with the next person chatting. Well, it's easy to make things when you're happy. Time is precious, but still hope your learning curve is not too steep, I hope you can happily enter the new field.

Tensorflow-gpu, Cuda, CUDNN installation on Windows

Related Article

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.