这更像是一个杂项问题,但是否有一个功能可以做到这一点?我只是找不到有关此主题的任何文档。例如,我的用法是这样的:
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
Run Code Online (Sandbox Code Playgroud)
目前我确实有办法做到这一点,但它相当笨拙:
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
Run Code Online (Sandbox Code Playgroud)
仅供参考,这是我正在研究的 colab:https ://colab.research.google.com/github/Namburger/edgetpu-ssdlite-mobiledet-retrain/blob/master/ssdlite_mobiledet_transfer_learning_cat_vs_dog.ipynb#scrollTo=Mg1C8UwStK7i