windows系统跑gpu版的tensorflow(用gpu运行程序)

1.安装好所有的工具,在代码主要部分前面加上os.environ[“CUDA_VISIBLE_DEVICES”] = '0’如果失败用win+R打开运行界面输入cmd,将路径位于C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi拖到cmd界面里,回车查看gpu的信息2.安装gpu版tensorflow时遇到ImportError: Co...
摘要由CSDN通过智能技术生成

1.安装好所有的工具,在代码主要部分前面加上os.environ[“CUDA_VISIBLE_DEVICES”] = '0’如果失败
用win+R打开运行界面输入cmd,将路径位于C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi拖到cmd界面里,回车查看gpu的信息
在这里插入图片描述
2.安装gpu版tensorflow时
遇到ImportError: Could not find ‘cudart64_100.dll’
就是你的cuda的版本过低,建议安装cuda10.0以上的版本
3.判断你的tensorflow-gpu使用cpu还是gpu运行?
运行以下代码,观察输出的日志,有cpu就是使用cpu,有gpu就是使用gpu

with tf.device('/cpu:0'):
  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)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
prin
  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值