当前位置:   article > 正文

tensorflow测试GPU可用

tensorflow测试gpu

因为自己在实现yolo5的过程中其中所需要的的环境是cuda10.1但是在之前安装的是10.0,所以只有自己折腾一下。但是cuda10.1貌似很难安装tensorflow1.X版本,在查阅资料并亲测过之后写下。
二、电脑环境
1.win10专业版
2.CUDA=10.1
3.显卡=1080TI
4.vs2015
三、安装
1.具体的安装步骤就不在这做详细说明,具体可以去看https://blog.csdn.net/weixin_43218120/article/details/107708082
在上面的博客中有详细说明。
2.问题解决
解决安装tensorflow-gpu1.X版本问题只需要在安装tensorflow-gpu之前安装cudatoolkit=10.0的包,具体的安装命令如下:

conda install cudatoolkit=10.0
1
在安装cudatoolkit之后再进行安装tensorflow就成功。
四、测试
1.测试代码

  1. import tensorflow as tf
  2. hello = tf.constant('Hello, TensorFlow!')
  3. sess = tf.Session()
  4. print(sess.run(hello))
  5. print(tf.test.is_gpu_available())
  6. print(tf.__version__)

或者

  1. import tensorflow as tf
  2. with tf.device('/gpu:0'):
  3. a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
  4. b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
  5. c = tf.matmul(a, b)
  6. with tf.Session() as sess:
  7. print (sess.run(c))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/181501
推荐阅读
相关标签
  

闽ICP备14008679号