Fly-ShuAI commited on
Commit
0a0582d
verified
1 Parent(s): 2bba75d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -4,16 +4,11 @@ print('device:', device)
4
  torch_version = torch.__version__
5
  print('torch_version:', torch_version)
6
 
7
- # 鑾峰彇鏈嶅姟鍣╟uda鐗堟湰
8
- def get_cuda_version():
9
- try:
10
- import torch
11
- cuda_version = torch.version.cuda
12
- if cuda_version is None:
13
- return "CUDA version not found"
14
- return cuda_version
15
- except ImportError:
16
- return "PyTorch is not installed"
17
-
18
- cuda_version = get_cuda_version()
19
- print('cuda_version:', cuda_version)
 
4
  torch_version = torch.__version__
5
  print('torch_version:', torch_version)
6
 
7
+ # 鑾峰彇鏈哄櫒鐨凜UDA鐗堟湰
8
+ # 鍦ㄦ満鍣ㄤ腑杈撳叆鍛戒护nvidia-smi
9
+ import subprocess
10
+ try:
11
+ result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
12
+ print('nvidia-smi output:', result.stdout)
13
+ except Exception as e:
14
+ print(f'Error: {e}')