manjaro19.01两行代码配置TensorFlow-gpu,cuda,cudnn(超简单,亲测!!!!)

#配置#
×系统:manjaro19.01×
×CPU:i7-9750h×
×GPU:gtx1660ti×
×无核显×

#1.安装最新版的cuda和cudnn

sudo pacman -S cuda cudnn

上述命令为最新版本cuda和cudnn
若不想要最新版本可用 yay命令安装
在这里插入图片描述
#编译(大概30分钟)

cd /opt/cuda/samples/bin/x86_64/linux/release
./deviceQuery

#2.安装TensorFlow-gpu

pip install tensorflow-gpu==1.15
或者
pip install tensorflow-gpu==2.0

#3.验证安装是否成功和是够为gpu版本

import tensorflow as tf
# 新建一个 graph
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# 新建session with log_device_placement并设置为True
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# 运行这个 op
print (sess.run(c))
#任务完成,关闭会话
sess.close()

运行结果:

Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
/job:localhost/replica:0/task:0/device:XLA_GPU:0 -> device: XLA_GPU device
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 1660 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5

[[22. 28.]
 [49. 64.]]
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值