查看机器 GPU
的信息:
nvidia-smi
持续更新查看:
nvidia-smi -l
其他方式如下:
import os
# 使用GPU0 和 GPU1
os.environ['CUDA_VISIBLE_DEVICES'] = '0, 1'
# 通过 allow_soft_placement 参数自动将无法放在 GPU 上的操作放回 CPU
gpuConfig = tf.ConfigProto(allow_soft_placement=True)
# 限制一个进程使用 60% 的显存
gpuConfig.gpu_options.per_process_gpu_memory_fraction = 0.6
# 运行时需要多少再给多少
gpuConfig.gpu_options.allow_growth = True
with tf.Session(config=gpuConfig) as sess:
pass
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有