当前位置:网站首页>服务器自动抢占GPU运行程序
服务器自动抢占GPU运行程序
2022-07-19 18:56:00 【非线性光学元件】
其原理是通过nvidia-smi扫描每块显卡上的内存,然后查询已经使用的内存,若已经使用的显卡内存不大于一个阈值,则运行python脚本(你也可以替换成别的命令)
#!/bin/bash
var=0
ocp_memory=${2:-500}
while [ $var -eq 0 ]
echo 'waiting for available gpu...'
do
count=0
for i in $(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits)
do
if [ $i -lt ocp_memory ]
then
echo 'GPU'$count' is avaiable'
CUDA_VISIBLE_DEVICES=$count python ${1}
var=1
break
fi
count=$(($count+1))
done
done
使用时的命令为
sh ocp_gpu.sh test.py 500
test.py即需要运行的py文件,500代表显卡被占有内存小于等于500MB。
边栏推荐
- 这才是做了5年的软件测试人员该有的样子...
- SQL Server database backup and recovery measures
- JS whether a certain time is within a certain time range
- 5.搜索二维矩阵
- STM32开发笔记119:使能FPU需要哪些宏?
- Baklib:分享一些关于建设企业知识管理(KM)的方法
- Codeforces Round #809 (Div. 2)
- Translation of question a of 2020 Asia Pacific mathematical modeling competition
- Opencv learning materials sharing: Chinese, graphics and text, code notes are both abundant, and it is recommended to collect them
- 银行业数据安全建设专题分析
猜你喜欢
TCP相关知识及面试考点详解
2022-7-15总结
文献阅读十一—OpenAttack: An Open-source Textual Adversarial Attack Toolkit
【全局唯一id】分库分表之后,id 主键如何处理?
你的技术leader不懂这个?没有它就是没有设计的完成思考过程
Programming examples of stm32f1 and stm32subeide -hmc5883 electronic compass drive
Paper Time 回顾|MB2:为自治数据库建立行为模型
【无标题】
STM32F1与STM32CubeIDE编程实例-BH1750环境光强度传感器驱动
A game research and development company in Shenzhen installed monitoring for each station. Netizen: it's comparable to imprisonment!
随机推荐
CAD框选对象的两种方式、AUTOCAD——删除重复线段
Programming examples of stm32f1 and stm32subeide -bmp280 pneumatic temperature sensor drive
力扣第三题——无重复字符的最长子串
通过重写 OpenFeign 客户端实现自定义日志存储
Setting up Paths
Literature reading Xi - openattack: an open source textual advantageous attack Toolkit
5、复杂图网络
Uzbek President zelenski dismissed deputy director of the National Security Agency
基础测试干了4年,自学了自动化(太片面),突然接到被裁员消息
Gee (7): Gee plug-in open earth engine extension improves efficiency
A game research and development company in Shenzhen installed monitoring for each station. Netizen: it's comparable to imprisonment!
Anfulai embedded weekly report no. 274: 2022.07.11--2022.07.17
Brain tumor segmentation using deep learning +hybridresunet brain glioma segmentation brats + paper interpretation
Club + development process + mental process + reasons for failure + on the road again
6.寻找重复数
STM32开发笔记117:使用Matlab生成IIR低通滤波器系数
50 hot searches in July! Jay Chou's new album 150million a day! The marketing path of singers' new songs becoming popular
Minitouch click principle
QQ客服咨询随滚动条滚动(右边)
Custom attribute operation of DOM series