keras 指定程序在某块卡上训练实例
作者:BYR_jiandong 时间:2023-07-15 09:15:42
场景:某台机器上有三块卡,想同时开三个程序,放到三块卡上去训练。
策略:CUDA_VISIBLE_DEVICES=1 python train.py就可以指定程序在某块卡上训练。
补充知识:keras指定GPU及显存使用量
指定GPU
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
指定GPU和显存使用量
import os
from keras.backend.tensorflow_backend import set_session
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.3
set_session(tf.Session(config=config))
指定GPU显存使用按需分配
import keras.backend.tensorflow_backend as KTF
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
KTF.set_session(sess)
来源:https://blog.csdn.net/lujiandong1/article/details/60587035?
标签:keras,训练
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
用Python的Django框架来制作一个RSS阅读器
2023-01-31 19:17:33
![](https://img.aspxhome.com/file/2023/6/66406_0s.jpg)
python中模块导入模式详解
2022-04-03 08:54:29
![](https://img.aspxhome.com/file/2023/4/109474_0s.png)
Python数据结构与算法之完全树与最小堆实例
2021-01-10 06:58:47
详解Vue用cmd创建项目
2024-05-21 10:16:38
![](https://img.aspxhome.com/file/2023/9/125289_0s.png)
基于Python实现成语填空游戏的示例代码
2021-09-17 18:09:05
![](https://img.aspxhome.com/file/2023/3/128793_0s.png)
Vue实现页面添加水印功能
2024-04-28 09:24:06
HTML 5 Video概述
2010-06-23 18:56:00
![](https://img.aspxhome.com/file/UploadPic/20106/23/01-80s.jpg)
如何用ASP创建日志文件
2008-03-10 17:27:00
mysql ERROR 1045 (28000)问题的解决方法
2024-01-16 23:24:32
![](https://img.aspxhome.com/file/2023/0/121270_0s.jpg)
解决Pycharm 运行后没有输出的问题
2023-06-02 04:48:19
![](https://img.aspxhome.com/file/2023/9/90889_0s.jpg)
基于并发服务器几种实现方法(总结)
2021-12-30 16:18:09
golang接口IP限流,IP黑名单,IP白名单的实例
2024-04-25 15:18:14
Dlib+OpenCV深度学习人脸识别的方法示例
2022-11-08 06:34:42
![](https://img.aspxhome.com/file/2023/3/72063_0s.png)
一文详解golang通过io包进行文件读写
2024-05-09 10:07:52
Go与C语言的互操作实现
2024-02-04 08:39:28
SQL Server中修改“用户自定义表类型”问题的分析与方法
2024-01-24 01:13:58
![](https://img.aspxhome.com/file/2023/9/108529_0s.png)
不安全的js写法
2009-09-16 14:26:00
python 的 scapy库,实现网卡收发包的例子
2021-08-08 17:25:05
MSMQ微软消息队列详解
2024-05-03 15:32:00
![](https://img.aspxhome.com/file/2023/3/129703_0s.jpg)
javascript下判断一个元素是否存在的代码
2024-04-18 10:12:41