!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
google colab要挂载在当前目录
!ls
进入当前文件夹,更换目录
import sys
from google.colab import drive
# 这个命令是将Drive挂载到‘/content/drive’下,查看此时的目录就知道了
drive.mount('/content/drive')
# 加入系统路径
sys.path.append('/content/drive/MyDrive/Palmprint')
# 进入当前路径
%cd /content/drive/MyDrive/Palmprint
torch.cuda.is_available()
cuda是否可用;
torch.cuda.device_count()
返回gpu数量;
torch.cuda.get_device_name(0)
返回gpu名字,设备索引默认从0开始;
torch.cuda.current_device()
返回当前设备索引;
!/opt/bin/nvidia-smi
查看GPU情况