Spaces:
Running
on
Zero
Running
on
Zero
Update main.py
Browse files
main.py
CHANGED
@@ -29,40 +29,27 @@ for i in range(device_count):
|
|
29 |
|
30 |
import os
|
31 |
|
32 |
-
nvidia_devices = [dev for dev in os.listdir('/dev') if dev.startswith('nvidia')]
|
33 |
-
print("NVIDIA 设备文件:", nvidia_devices)
|
34 |
-
for dev in nvidia_devices:
|
35 |
-
path = os.path.join('/dev', dev)
|
36 |
-
print(f"设备 {path} 的权限:", oct(os.stat(path).st_mode))
|
37 |
-
import ctypes
|
38 |
-
|
39 |
-
try:
|
40 |
-
ctypes.CDLL('libcuda.so')
|
41 |
-
print("CUDA 库已加载。")
|
42 |
-
except Exception as e:
|
43 |
-
print("无法加载 CUDA 库,错误信息:", e)
|
44 |
-
|
45 |
-
import os
|
46 |
-
|
47 |
-
cuda_visible_devices = os.environ.get('CUDA_VISIBLE_DEVICES', '未设置')
|
48 |
-
print("CUDA_VISIBLE_DEVICES:", cuda_visible_devices)
|
49 |
-
|
50 |
try:
|
51 |
-
|
52 |
-
|
53 |
-
print("CUDA 张量创建成功:", x)
|
54 |
except Exception as e:
|
55 |
-
print("
|
56 |
|
57 |
-
import
|
58 |
|
59 |
-
|
|
|
|
|
60 |
try:
|
61 |
-
|
62 |
-
|
63 |
-
print("GPU 信息:", gpu_info)
|
64 |
except Exception as e:
|
65 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
|
68 |
def run_main(
|
|
|
29 |
|
30 |
import os
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
try:
|
33 |
+
ctypes.CDLL('libnvidia-ml.so')
|
34 |
+
print("成功加载 libnvidia-ml.so。")
|
|
|
35 |
except Exception as e:
|
36 |
+
print("无法加载 libnvidia-ml.so,错误信息:", e)
|
37 |
|
38 |
+
import glob
|
39 |
|
40 |
+
libs = glob.glob('/usr/lib*/**/libnvidia-*.so*', recursive=True)
|
41 |
+
print("NVIDIA 驱动库文件:", libs)
|
42 |
+
print("LD_LIBRARY_PATH:", os.environ.get('LD_LIBRARY_PATH', '未设置'))
|
43 |
try:
|
44 |
+
with open('/proc/driver/nvidia/version') as f:
|
45 |
+
print(f.read())
|
|
|
46 |
except Exception as e:
|
47 |
+
print("无法读取驱动程序版本信息,错误信息:", e)
|
48 |
+
print("PyTorch 安装路径:", torch.__file__)
|
49 |
+
cuda_paths = [path for path in os.listdir('/usr/local') if path.startswith('cuda')]
|
50 |
+
print("CUDA 安装路径:", cuda_paths)
|
51 |
+
print("PyTorch CUDA 版本:", torch.version.cuda)
|
52 |
+
print("系统 CUDA 版本:", os.environ.get('CUDA_VERSION', '未设置'))
|
53 |
|
54 |
|
55 |
def run_main(
|