In step Windows 10 using the Anaconda installation TensorFlow gpu 2.0

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/hung22/article/details/102750455

In Windows 10 using the Anaconda TensorFlow 2.0 GPU steps to install: (not required in nivida website, download the driver)

1 . Download and install the Anaconda
https://www.anaconda.com/distribution/

2. Installation Anaconda rear , open Anaconda Prompt input .

       conda create -n your_env_name python=3.7 cudnn cudatoolkit=10.0

3. enter your_env_name environment

       conda activate your_env_name

4. Then input , installation Tensorflow-2.0 GPU .

       pip install tensorflow-gpu

Then install TensorFlow-gpu 2.0 finished.

 

 

Test.py can use the following test ( this example is quoted from the Internet)

import tensorflow as tf

import timeit

with tf.device('/cpu:0'):

    cpu_a =tf.random.normal([10000,1000])

    cpu_b =tf.random.normal([1000,2000])

    print(cpu_a.device,cpu_b.device)

 

with tf.device('/gpu:0'):

    gpu_a =tf.random.normal([10000,1000])

    gpu_b =tf.random.normal([1000,2000])

    print(gpu_a.device,gpu_b.device)

 

def cpu_run():

    with tf.device('/cpu:0'):

        c = tf.matmul(cpu_a,cpu_b)

        return c

def gpu_run():

    with tf.device('/gpu:0'):

        c = tf.matmul(gpu_a,gpu_b)

        return c

 

cpu_time = timeit.timeit(cpu_run, number=10)

gpu_time = timeit.timeit(gpu_run, number=10)

print('warmup: ',cpu_time,gpu_time)

 

cpu_time = timeit.timeit(cpu_run, number=10)

gpu_time = timeit.timeit(gpu_run, number=10)

print('run time: ',cpu_time,gpu_time)

Guess you like

Origin blog.csdn.net/hung22/article/details/102750455