前提:代理選“德國”,穩定一點 ~
1. 將Colab與Good Drive關聯起來
from google.colab import drive drive.mount('/content/drive')
2.定位到Drive的根目錄,並查看根目錄下的文件
import os os.chdir("/content/drive/My Drive") !ls
3.下載GitHub的代碼到Drive
!git clone https://github.com/wadayama/TISTA.git
!ls
4. 切換到剛才下載項目的文件夾下
cd TISTA/
5.查看文件夾下所有文件
!ls
6.修改TensorFlow版本為1.X,Colab默認使用TensorFlow 2.X
%tensorflow_version 1.1 import tensorflow print(tensorflow.__version__)
7. 運行python程序
!python main.py
7.1 運行Python程序,並在notebook上顯示plt圖片
#!python main.py #下面的運行方式 % run main.py %matplotlib inline
如何查看GPU?
! /opt/bin/nvidia-smi
在本地如何TensorFlow2.0下運行TensorFlow1.X版本的代碼
import tensorflow as tf #-----修改為↓↓↓↓↓↓↓↓↓ import tensorflow.compat.v1 as tf tf.disable_v2_behavior()
參考:
https://blog.csdn.net/tan123456987321/article/details/104777049
colab+git clone+Google drive提速: https://blog.csdn.net/qq_42698608/article/details/104793387