<> Preparation stage :
* Anaconda 3( Download from official website )
* python3.x(Anaconda3 Bring your own )
* GPU( minimum NVDIA GTX 650)
* tensorflow-gpu(Anaconda Installation in )
* tensorflow Basic grammar operation
<> Code testing
Write a manual call gpu Device code
# coding:utf-8 ''' ************************************************** @File
: Deep learning practice [ Antonio ] -> Cap1-hello world @IDE :PyCharm @Author :Small_wind @Date
:2019/11/17 10:46 ************************************************** ''' import
tensorflowas tf ##1. Let's write one first hello world Under test message=tf.constant("hello world")# Constant string
sess=tf.Session() print(sess.run(message)) sess.close() ##2. constant , variable # Skip
##3. call GPU/CPU equipment c=[] with tf.device('/gpu:0'): rand_t=tf.random_uniform([50,50],
0,10,dtype=tf.float32,seed=0) a=tf.Variable(rand_t) b=tf.Variable(rand_t) c.
append(tf.matmul(a,b)) init=tf.global_variables_initializer()
# To verify Tensorflow Are you sure you want to reuse the specified device , Settable log_device_placement=True sess=tf.Session(config=tf
.ConfigProto(log_device_placement=True)) sess.run(init) print(sess.run(c)) sess.
close()
<> result
of course , stay Anaconda Installed tensorflow-gpu After version , When you run the program later , Will be automatically called first gpu Of ( If so gpu)
Technology
Daily Recommendation