uuntu 16.04 TensorFlow GPUバージョンをインストールする

12702 ワード

uuntu 16.04にcuda 8.0とcudnnをインストールします。 5.1以下の内容を参照してください。 
http://blog.csdn.net/chenhaifeng2016/article/details/68957732
TensorFlowをインストールする
sudo ap-get install libcupti-dev
sudo ap-get install python-pip python-dev python-virtulenv
virtual lenv--system-site-packages~/tenssor flow
source~/tenssor flow/bin/activate
pip install--up grade tenssor flow-gpu
テストTensorFlow
Pycharmで試験工程を作成する
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf

global mnist

#    MNISTMNIST_data    def DownloadData():
    global mnist
    mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)  #one-hot  print(mnist.train.images.shape, mnist.train.labels.shape)
    print(mnist.test.images.shape, mnist.test.labels.shape)
    print(mnist.validation.images.shape, mnist.validation.labels.shape)

def Train():
    sess = tf.InteractiveSession()

    #Step 1  #      Softmax Regression  x = tf.placeholder(tf.float32, [None, 784])            #     ,       ,None               W = tf.Variable(tf.zeros([784,10]))                    #weights0  b = tf.Variable(tf.zeros([10]))                        #biases0  y = tf.nn.softmax(tf.matmul(x, W) + b)                 #     softmaxy = softmax(Wx + b)y             #Step 2  #      ,     ,              y_ = tf.placeholder(tf.float32, [None, 10])             #  #          cross_entropy = -tf.reduce_sum(y_ * tf.log(y))
    #y = tf.matmul(x, W) + b  #cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y))   # 0.01 train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)


    #Step 3  #              tf.global_variables_initializer().run()
    for i in range(1000):                                                  #     1000  batch_xs, batch_ys = mnist.train.next_batch(100)                   #  minibatchbatch    100  sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})        #                  #Step 4  #               correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))          #tf.argmax() accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))      #              print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))  #         sess.close()

if __name__ == '__main__':
    DownloadData();
    Train();
実行効果
//home/chenhf/tensowflow/bin/python/home/chenhf/PycharmProject/Tensow Test/MnistDemo.py I tensflow/streamexector/dso_loader.cc:135]success fully opened CUDA library libcublas.so.8.0 localy I tenssor flow/strem_exector/dso_loader.cc:126]Couldn't open CUDA library libcudnn.so.LD_リブラアルPATH:/home/chenhf/pycharm-2017.1/bin:/usr/local/cuda-85.0/lib 64:I tenssor flow/stream_exector/cuda/cuda_dnn.cc:3517]Unbale to load cuDNN DSO I tenssor flow/stream_exector/dso_loader.cc:135]success fully opened CUDA library libcufft.so.8.0 localy I tenssor flow/strem_exector/dso_loader.cc:135]success fully opened CUDA library libcuda.so.1 localy I tenssor flow/stream_exector/dso_loader.cc:135]success fully opened CUDA librand.so.8.0 locallly Extracting MNIST_data/trin-mages-indx 3-ubyte.gz Extracting MNIST_data/trin-labels-indx 1-ubyte.gz Extracting MNIST_data/t 10 k-mages-indx 3-ubyte.gz Extracting MNIST_data/t 10 k-labels-indx 1-ubyte.gz(55000,784)、(55000,10)W tenssor flow/core/plutform/cpu_フィーチャーgurd.cc:45)The TensorFlow library wasn't compled to use SSE 3 instructions,but these are available on your machine and could speed up CPU coputtations.(10000,784),(10000,10)(5,000,785,000)フィーチャーgurard.cc:45]The TensorFlow library wasn't compled to use SSE 4.1 instructions,but these these are available on your machine and could speed up CPU computtions.W tens flow/core/plutform/cpuフィーチャーgurard.cc:45]The TensorFlow library wasn't compled to use SSE 4.2 instructions,but these there available on your machine and could speed up CPU coputtions.W tens flow/core/plutform/cpuフィーチャーgurard.cc:45]The TensorFlow library wasn't compled to use AVX instructions,but these are available on your machine and could speed up CPU coputtions.W tesorflow/core/plutform/cpuフィーチャーgard.cc:45]The TensorFlow library wasn't compled to use AVX 2 instructions,but these are available on your machine and could speed up CPU computtions.W tens/corn/playform/cpuフィーチャーgurard.cc:45]The TensorFlow library wasn't compled to use FMA instructions,but these are available on your machine and could speed up CPU coputtions.I tens flow/streamexector/cuda/cuda_gpuexector.c:910]success ful NUMA node read from SysFS had negative value(-1)、but there must be at least one NUMA node、so returning NUMA nodeゼロI tensoflow/commonruntime/gpu/gpudevice.c:885]Found device 0 with properties:  name:GeForce GTX 765 M major:3 minor:0 memory Clock Rate(GHz)0.8625 pciBusID 0000:01:00.0 Total memory:1.95 GiB Free memory:1.93 GiB I tensflow/compmonruntime/gpu/gpudevice.c:906]DMA:0  I tenssor flow/core/comon_runtime/gpu/gpudevice.c:916]0:  Y  I tenssor flow/core/comon_runtime/gpu/gpudevice.cc:975]Creating TensorFlow device(/gpu:0)-』(device:0,name:GeForce GTX 765 M,pci bus id:0000:01:00.0)0.9162 Process finished with exit code 0
正確率は91.6%です
--終了--