zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Google-GPU使用方法

Google方法 GPU 使用
2023-09-14 09:15:31 时间

Colaboratory是一个 Google 研究项目,旨在帮助传播机器学习培训和研究成果。它是一个Jupyter Notebook环境,不需要进行任何设置就可以使用,并且完全在云端运行。网站:https://colab.research.google.com/

测试代码:
在这里插入图片描述
挂载google云盘方法:

!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}

查看显卡:
在这里插入图片描述
查看显卡使用上限:
在这里插入图片描述
安装库的方式:

安装Keras:

!pip install -q keras
import keras
安装PyTorch:

!pip install -q http://download.pytorch.org/whl/cu75/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl torchvision
import torch
安装OpenCV:

!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
安装XGBoost:

!pip install -q xgboost==0.4a30
import xgboost
安装GraphViz:

!apt-get -qq install -y graphviz && pip install -q pydot
import pydot
安装7zip Reader:

!apt-get -qq install -y libarchive-dev && pip install -q -U libarchive
import libarchive
安装其他库:


用!pip install或者!apt-get install命令。

查看系统层面信息:
在这里插入图片描述
在这里插入图片描述

本地运行时支持
Colab 支持连接本地计算机上的 Jupyter 运行;这样一来,您就可以在本地硬件上执行代码并访问本地文件系统。

!pip install jupyter_http_over_ws

打开Anaconda Prompt,输入命令:

jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com'  --port=8899 --NotebookApp.port_retries=0

参考教程:https://blog.csdn.net/jacka654321/article/details/83928187
在这里插入图片描述
运行之后:
在这里插入图片描述

详细参考文献:
https://blog.csdn.net/angus_monroe/article/details/79542843

https://blog.csdn.net/yyzsir/article/details/100566802

参考使用方法:
https://blog.csdn.net/jacka654321

代码案例:
https://blog.csdn.net/jacka654321/article/details/83928187