You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
794 B
Python
31 lines
794 B
Python
import torch
|
|
|
|
print("PyTorch 버전:", torch.__version__)
|
|
|
|
# CUDA 사용 가능 여부 확인
|
|
if torch.cuda.is_available():
|
|
print("CUDA is available! Testing CUDA...")
|
|
|
|
# CUDA 디바이스 설정
|
|
device = torch.device("cuda")
|
|
|
|
# CUDA 디바이스에 텐서를 생성하고 연산 수행
|
|
x = torch.rand(5, 5, device=device)
|
|
y = torch.rand(5, 5, device=device)
|
|
z = x + y
|
|
|
|
# 결과 출력
|
|
print("Successfully performed a CUDA operation:")
|
|
print(z)
|
|
else:
|
|
print("CUDA is not available.")
|
|
|
|
|
|
# PyTorch 버전 확인
|
|
print("PyTorch version:", torch.__version__)
|
|
|
|
# CUDA 사용 가능 여부 및 버전 확인
|
|
cuda_available = torch.cuda.is_available()
|
|
print("CUDA available:", cuda_available)
|
|
if cuda_available:
|
|
print("CUDA version:", torch.version.cuda) |