1/30/2024

checking torch + cuda installed correctly

 

 

Run this script 

.

 

import torch
from torch.utils.cpp_extension import CUDAExtension, BuildExtension

def check_cuda_setup():
cuda_available = torch.cuda.is_available()
print(f"CUDA available: {cuda_available}")

if cuda_available:
cuda_version = torch.version.cuda
print(f"CUDA version (PyTorch): {cuda_version}")

try:
# Attempt to create a CUDA extension
ext = CUDAExtension(
name='test_ext',
sources=[]
)
print("CUDAExtension can be created successfully.")
except Exception as e:
print(f"Error creating CUDAExtension: {e}")

try:
# Attempt to create a BuildExtension object
build_ext = BuildExtension()
print("BuildExtension can be created successfully.")
except Exception as e:
print(f"Error creating BuildExtension: {e}")

if __name__ == "__main__":
check_cuda_setup()


..

If return 'False' then you need to fix your system.

Thank you.


No comments:

Post a Comment