Colab運行GitHub代碼


前提:代理選“德國”,穩定一點 ~

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM