Open Pin-Jiun opened 2 years ago
.ipynb 是 ipython NoteBook的簡寫, 是Juputer所使用的一種檔案形式
GPU
確認電腦是否有GPU(Graphics Processing Unit), 並確認是否有CUDA
CUDA(Compute Unified Device Architecture,統一計算架構)是由輝達NVIDIA所推出的一種整合技術,是該公司對於GPGPU的正式名稱。 透過這個技術,使用者可利用NVIDIA的GPU進行圖像處理之外的運算,亦是首次可以利用GPU作為C-編譯器的開發環境。
cuDNN(CUDA Deep Neural Network library):是NVIDIA打造的針對深度神經網絡的加速庫,是一個用於深層神經網絡的GPU加速庫。 如果你要用GPU訓練模型,cuDNN不是必須的,但是一般會采用這個加速庫。
測試 CUDA 是否安裝成功,若安裝成功會輸出 CUDA 版本資訊
nvcc -V
如果上述找不到, 記得將以下的位置加入環境變數中的Path中
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin
import torch
print(torch.cuda.is_available())
要移動到GPU的包括
When would I use model.to("cuda:1") as opposed to model.to("cuda:0")?
import torch
print(torch.cuda.get_device_name(torch.device('cuda:0')))
NVIDIA GPU in your case, the AMD GPU isn't visible as a cuda device, feel safe to assume cuda:0 is only a CUDA enabled GPU, and 沒有CUDA enabled GPU won't be seen by your program
nvidia-smi
What is Colab?
Colab, or "Colaboratory", allows you to write and execute Python in your browser, with ● Zero configuration required ● Free access to GPUs ● Easy sharing
You can type python code in the code cell or use a leading exclamation mark
!
to change the code cell to treating the input as a shell scriptUsing an exclamation mark (!) starts a new shell, does the operations, and then kills that shell, while percentage (%) affects the process associated with the notebook, and it is called a magic command.
Use
%
instead of ! for cd (change directory) commandGPU
click on "Runtime"(執行階段) → "Change Runtime Type"(變更執行階段類型)→ select "GPU" for "Hardware Accelerator"(硬體加速器)
Check GPU Type
Use the command
nvidia-smi
to check the allocated GPU type Available GPUs: P100 > T4 > K80File Manipulation
Download files via Google Drive
每個notebook有屬於自己的專屬資料夾,可以Mounting Google Drive
如果要打包下載 使用以下指令