Spaces:
Running
on
Zero
Running
on
Zero
import torch | |
device = f'cuda:0' if torch.cuda.is_available() else 'cpu' | |
print('device:', device) | |
torch_version = torch.__version__ | |
print('torch_version:', torch_version) | |
# 获取服务器cuda版本 | |
def get_cuda_version(): | |
try: | |
import torch | |
cuda_version = torch.version.cuda | |
if cuda_version is None: | |
return "CUDA version not found" | |
return cuda_version | |
except ImportError: | |
return "PyTorch is not installed" | |
cuda_version = get_cuda_version() | |
print('cuda_version:', cuda_version) |