tensorflow gpu安装_快速收藏:NVIDIA与tensorflow-gpu版本匹配成功安装TF

9a76f9bf4a3285260c6c083ac4826c11.png

首先查看自己的NVIDIA 版本(如果没有请自行下载一个安装):

参考:https://blog.csdn.net/weixin_41194129?spm=1001.2101.3001.5113

电脑终端输入:nvcc -V

执行结果:

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2019 NVIDIA Corporation

Built on Wed_Oct_23_19:32:27_Pacific_Daylight_Time_2019

Cuda compilation tools, release 10.2, V10.2.89

说明我的版本是V10.2.89,因此要找与之对应的tensorflow-gpu:

TensorFlow - FloydHub Documentation​docs.floydhub.com
5b15c1251051e0e6fcfdba57d7e94d2c.png

45f552f7cacae399cc82acce6df425b0.png

因此安装gpu命令为:

pip install --index-url https://pypi.douban.com/simple tensorflow-gpu==2.2.0

成功安装后检验一下是不是gpu,建立一个.py文件,在该编译环境下写入:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

执行结果:

name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 1442306457
locality {
  bus_id: 1
  links {
  }
}
incarnation: 90673536119032307
physical_device_desc: "device: 0, name: GeForce MX130, pci bus id: 0000:02:00.0, compute capability: 5.0"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 7580331184281744497
physical_device_desc: "device: XLA_GPU device"
]

或者直接使用下面最直观的查询方式:

# import tensorflow as tf
from tensorflow.python.client import device_lib

# 列出所有的本地机器设备
local_device_protos = device_lib.list_local_devices()
# 打印
#     print(local_device_protos)

# 只打印GPU设备
[print(x) for x in local_device_protos if x.device_type == 'GPU']

执行结果:

2020-11-29 15:16:26.750915: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/device:GPU:0 with 1375 MB memory) -> physical GPU (device: 0, name: GeForce MX130, pci bus id: 0000:02:00.0, compute capability: 5.0)
2020-11-29 15:16:26.754064: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x178e7306f60 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-11-29 15:16:26.754323: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce MX130, Compute Capability 5.0
name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 1442306457
locality {
  bus_id: 1
  links {
  }
}
incarnation: 13018729120500724821
physical_device_desc: "device: 0, name: GeForce MX130, pci bus id: 0000:02:00.0, compute capability: 5.0"

测试成功!

2518a2d4be5ff9196420630217037621.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值