首页 技术 正文
技术 2022年11月11日
0 收藏 837 点赞 2,475 浏览 1539 个字

今天发现一个怪现象,在训练keras时,发现不使用GPU进行计算,而是采用CPU进行计算,导致计算速度很慢。

用如下代码可检测tensorflow的能使用设备情况:

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

可用设备为:

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}]  

原来只有一个CPU设备可用了。于是检查下tensorflow的版本情况:

pip3 list

各应用版本为:

tensorflow          1.10.1
tensorflow-gpu 1.9.0

原来我升级了tensorflow版本,忘记了升级tensorflow-gpu版本,现在两个版本有代差,而tensorflow默认选择版本高的CPU版本来计算了。

那就升级tensorflow-gpu吧:

pip3 install --index-url http://pypi.douban.com/simple --trusted-host pypi.douban.com --upgrade tensorflow-gpu

再次检测可用设备情况,结果如下:

-- ::22.996654: I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Found device  with properties:
name: GeForce GTX 5GB major: minor: memoryClockRate(GHz): 1.7085
pciBusID: ::00.0
totalMemory: .94GiB freeMemory: .23GiB
-- ::22.996666: I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Adding visible gpu devices:
-- ::23.189923: I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Device interconnect StreamExecutor with strength edge matrix:
-- ::23.189953: I tensorflow/core/common_runtime/gpu/gpu_device.cc:]
-- ::23.189959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:] : N
-- ::23.190105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:] Created TensorFlow device (/device:GPU: with MB memory) -> physical GPU (device: , name: GeForce GTX 5GB, pci bus id: ::00.0, compute capability: 6.1)
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit:
locality {
}
incarnation:
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit:
locality {
bus_id:
links {
}
}
incarnation:
physical_device_desc: "device: 0, name: GeForce GTX 1060 5GB, pci bus id: 0000:01:00.0, compute capability: 6.1"
]
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291