Getting tensorflow2.0 (1): GPU version environment to build Win10 + Cuda10 + cudnn7.6.3

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/id_iot/article/details/102753243

Foreword

After the first half of this year TensorFlow2.0 release, currently growing gradually learning materials, is a good time to start.

image

The upgrade can be said that unprecedented efforts, the next period of time will tensorflow2.0 write a theme: tensorflow2.0 started.

The first chapter begins operating environment to build tensorflow

First, the necessary configuration

  1. Anaconda3-2019.07-Windows-x86_64

    Download: https: //www.anaconda.com/distribution

  2. cuda_10.0.130_411.31_win10 (be careful not to under-date 10.1 does not support tf2.0)

    Download: https: //developer.nvidia.com/cuda-10.0-download-archive target_os = Windows & target_arch = x86_64 & target_version = 10 & target_type = exelocal?

  3. cudnn-10.0-windows10-x64-v7.6.3.30

    Download: https: //developer.nvidia.com/rdp/cudnn-download

  4. TensorFlow2.0

Computer basic situation:

image

Upon inquiry, the card can use the GPU version TensorFlow2.0, inquiries to:

https://developer.nvidia.com/cuda-gpus

Second, the installation configuration

1.anaconda installation

All the way to fool installation:

image

Add the anaconda installation path to the environment variable;

image

Add pycharm in anaconda for the project interpreter:

image

This will build a good environment to run a python.

2.cuda installation

Double-click fool install:

image

View the environment variables, CUDA and libnvvp of bin path is added to it:

image

3.cudnn installation

Decompression cudnn, obtain the following documents:

image

The three folders to copy, then paste it into C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v10.0, depending on their own path to change.

And after

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64

Added to the environment variable path.

4.tensorflow2.0 installation

By mounting the mirror faster speed

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==2.0.0a0

Third, the test code

After installation can be tested using the following code:

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

# warm up 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)

If the test results are as follows:

image

Congratulations on your success! ! !

No public attention, access to massive learning resources.

image

Exchange Group 1024 program developer community has been established, many small partners have been added, thank you for your support. We can exchange views on technical issues in the group, is not a member of the junior partner can scan under "community property" two-dimensional code, allowing administrators to help pull into the group, we expect to join.

image

//you may also like//

Guess you like

Origin blog.csdn.net/id_iot/article/details/102753243