python - 如何确定您是否在 colab 中安装了 colab pro?
问题描述
这更像是一个杂项问题,但有这样做的功能吗?我只是找不到有关此主题的任何文档。例如,我的用法是这样的:
from google.colab import utils # I made this up
colab_pro = utils.colab_is_pro()
if colab_pro:
# train model with higher settings
else:
# train model with lower settings
目前我确实有办法做到这一点,但它相当hacky:
gpu_name = !nvidia-smi --query-gpu=gpu_name --format=csv
# You get Tesla T4 with free colab and faster GPUs with colab pro
colab_pro = False if 'T4' in gpu_name else True
仅供参考,这是我正在研究的 colab: https ://colab.research.google.com/github/Namburger/edgetpu-ssdlite-mobiledet-retrain/blob/master/ssdlite_mobileet_transfer_learning_cat_vs_dog.ipynb#scrollTo=Mg1C8UwStK7i
解决方案
#A Colab pro environment should have >20Gb of total memory.
from psutil import virtual_memory
colab_pro = virtual_memory().total / 1e9
print('Your runtime has {:.1f} gigabytes of available RAM\n'.format(colab_pro))
if colab_pro < 20:
print('Not using a high-RAM runtime')
# train model with lower settings
else:
print('You are using a high-RAM runtime!')
# train model with higher settings
此外,您可以按如下方式检查 colab 中的可用内存:
!cat /proc/meminfo
Colab pro 环境的总内存应大于 20Gb。
https://colab.research.google.com/notebooks/pro.ipynb#scrollTo=V1G82GuO-tez
推荐阅读
- reactjs - 如何检查完全渲染的 React 子组件,包括其中的 AJAX 调用?
- r - 将 .byte 文件读入 R
- javascript - 响应式菜单未在单击时关闭
- ios - 未调用 IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken
- amazon-web-services - 具有 jenkins 构建阶段的代码管道的 AWS Cloudformation 模板
- xcode - 无法将下面的视图添加到情节提要中的标签
- azure - 来自特定文档的自定义技能的天蓝色搜索索引器的响应是:无法执行技能。WebApi 技能响应包含错误
- javascript - 在 nuxt.js 路由之后令牌未定义
- php - 在 Laravel 上读取上传的 CSV 时在每个字母之间获取未知字符
- react-native - 有没有办法在反应原生博览会中按下按钮重新加载应用程序?