linux安装tensorflow-gpu安装踩坑

cuda9.0+cudnn7.0+tensorflow-gpu1.9.0

cuda和cudnn网上的安装教程都有很多,这里我就不详细说了

查看cuda和cudnn是否安装成功:

cuda一般安装在 /usr/local/cuda/ 路径下,该路径下有一个version.txt文档,里面记录了cuda的版本信息

cat  /usr/local/cuda/version.txt 即可查询

同理,cudnn的信息在其头文件里

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2  即可查询

重点来了-----------------

tensorflow一定要装1.9.0,不然虽然安装好了,但是import tensorflow的时候就会报错

安装tensorflow用下面的语句:

pip install tensorflow-gpu==1.9.0

安装好之后用下列代码测试一下

import tensorflow as tf
tf.test.is_gpu_available()

会出现以下信息就说明gpu版本的装好了

2019-03-20 10:51:12.233358: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-03-20 10:51:12.635285: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:02:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2019-03-20 10:51:12.884465: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 1 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:04:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2019-03-20 10:51:13.072415: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 2 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:83:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2019-03-20 10:51:13.270321: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1392] Found device 3 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582
pciBusID: 0000:84:00.0
totalMemory: 10.92GiB freeMemory: 10.76GiB
2019-03-20 10:51:13.274725: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1471] Adding visible gpu devices: 0, 1, 2, 3
2019-03-20 10:51:14.588672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-03-20 10:51:14.588747: I tensorflow/core/common_runtime/gpu/gpu_device.cc:958]      0 1 2 3
2019-03-20 10:51:14.588765: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   N Y N N
2019-03-20 10:51:14.588778: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 1:   Y N N N
2019-03-20 10:51:14.588791: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 2:   N N N Y
2019-03-20 10:51:14.588803: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 3:   N N Y N
2019-03-20 10:51:14.590197: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/device:GPU:0 with 10413 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1)
2019-03-20 10:51:14.771710: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/device:GPU:1 with 10413 MB memory) -> physical GPU (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:04:00.0, compute capability: 6.1)
2019-03-20 10:51:14.992416: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/device:GPU:2 with 10413 MB memory) -> physical GPU (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:83:00.0, compute capability: 6.1)
2019-03-20 10:51:15.209922: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/device:GPU:3 with 10413 MB memory) -> physical GPU (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:84:00.0, compute capability: 6.1)
True

 

 

你可能感兴趣的:(linux安装tensorflow-gpu安装踩坑)