1. Install CUDA toolkit 11.8
※ WARNING : Please except for "Nsight VSE" to avoid Installation fail.
2. Download cuDNN (https://developer.nvidia.com/rdp/cudnn-archive)
3. Check your System Environment Variables
4. Copy cuDNN to CUDA Directory
5. Install python package for pytorch(python version 3.10)
CMD : conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
6. Check pytorch works fine.
import subprocess
import torch
def check_torch_cuda():
print("Checking PyTorch CUDA support...")
if torch.cuda.is_available():
print(f"CUDA is available in PyTorch. Device count: {torch.cuda.device_count()}")
print(f"CUDA version: {torch.version.cuda}")
print(f"PyTorch is running on device: {torch.cuda.get_device_name(0)}")
else:
print("CUDA is not available in PyTorch. Make sure the CUDA toolkit and drivers are properly installed.")
def check_nvidia_smi():
print("\nChecking NVIDIA System Management Interface (nvidia-smi)...")
try:
result = subprocess.run(["nvidia-smi"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0:
print("nvidia-smi output:\n")
print(result.stdout)
else:
print("nvidia-smi could not be executed. Error:\n")
print(result.stderr)
except FileNotFoundError:
print("nvidia-smi command not found. Ensure the NVIDIA drivers are installed and added to the system PATH.")
def main():
print("CUDA Installation Check")
print("========================\n")
check_torch_cuda()
check_nvidia_smi()
if __name__ == "__main__":
main()
댓글 없음:
댓글 쓰기