Foreword
After the first half of this year TensorFlow2.0 release, currently growing gradually learning materials, is a good time to start.
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
-
Anaconda3-2019.07-Windows-x86_64
Download: https: //www.anaconda.com/distribution
-
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?
-
cudnn-10.0-windows10-x64-v7.6.3.30
Download: https: //developer.nvidia.com/rdp/cudnn-download
-
TensorFlow2.0
Computer basic situation:
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:
Add the anaconda installation path to the environment variable;
Add pycharm in anaconda for the project interpreter:
This will build a good environment to run a python.
2.cuda installation
Double-click fool install:
View the environment variables, CUDA and libnvvp of bin path is added to it:
3.cudnn installation
Decompression cudnn, obtain the following documents:
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:
Congratulations on your success! ! !
No public attention, access to massive learning resources.
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.
//you may also like//