ENV / GPU

Havi·2023년 2월 28일
0

맥 터미널 명령어
https://yozm.wishket.com/magazine/detail/746/

쥬피터랩 아나콘다 가상환경만들기
https://wonhwa.tistory.com/50

wandb
https://minimin2.tistory.com/186
my
https://wandb.ai/home

실시간 gpu확인
https://velog.io/@claude_ssim/NVIDIA-GPU-%EB%B3%B4%EB%8A%94%EB%B2%95nvidia-smi

https://eungbean.github.io/2018/08/23/gpu-monitoring-tool-ubuntu/

nvidia-smi

gpu Util 99% 사용하기
https://ainote.tistory.com/14

gpu가 할당 되었는지 확인하기

# cuda:0 <- 특정 gpu사용하기 번호
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

print("Device:", device)

#	현재 cuda가 사용할  gpu를 명시
#	gpu를 다른 번호로 설정하여도 0으로 반환됨
print("Current cuda device:", torch.cuda.current_device())

#	현재 cuda가 사용할 gpu 개수를 명시

print("count of using GPUs:",torch.cuda.device_count())

모델에 gpu할당하기

model = model().to(device)

특정 gpu를 사용하는 경우

import os
import torch
import torch.nn as nn

os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
# 2번 gpu사용
os.environ["CUDA_VISIBLE_DEVICES"]= "2"

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

print('Device:', device)  # 출력결과: cuda 
print('Count of using GPUs:', torch.cuda.device_count())   #출력결과: 1 (GPU #2 한개 사용하므로)
print('Current cuda device:', torch.cuda.current_device())  # 출력결과: 2 (GPU #2 의미)

net = ResNet50().to(device)

cpu코어수 확인

import os
os.cpu_count()

pytorch

dataset/dataloader
https://hyen4110.tistory.com/m/71

randomseed

SEED = 2
torch.manual_seed(SEED)
torch.backends.cudnn.deterministic = False
torch.backends.cudnn.benchmark = False
np.random.seed(SEED)
profile
집중집중

0개의 댓글