I run the sparsity demo toy_problem.py, but got RuntimeError: CUDA error: invalid device function
Describe the Bug RuntimeError: CUDA error: invalid device function CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Minimal Steps/Code to Reproduce the Bug
apex/apex/contrib/sparsity/test/toy_problem.py
Expected Behavior
I run the demo toy_problem.py about sparsity, but got wrong
(torch) mdy@mdy:~/data/Te/apex/apex/contrib/sparsity/test$ python toy_problem.py Found permutation search CUDA kernels [ASP][Info] permutation_search_kernels can be imported. [ASP] torchvision is imported, can work with the MaskRCNN/KeypointRCNN from torchvision.
[set_permutation_params_from_asp] Set permutation needed parameters
[set_identical_seed] Set the identical seed: 1 for all GPUs to make sure the same results generated in permutation search
[ASP] Sparsifying linear_layer_1::weight of size=torch.Size([40, 16]) and type=torch.float32 for sparsity
[ASP] Not sparsifying linear_layer_1::bias of size=torch.Size([40]) and type=torch.float32
[ASP] Auto skipping pruning linear_layer_2::weight of size=torch.Size([40, 40]) and type=torch.float32 for sparsity
[ASP] Not sparsifying linear_layer_2::bias of size=torch.Size([40]) and type=torch.float32
[ASP] Auto skipping pruning linear_layer_3::weight of size=torch.Size([40, 40]) and type=torch.float32 for sparsity
[ASP] Not sparsifying linear_layer_3::bias of size=torch.Size([40]) and type=torch.float32
[ASP] Auto skipping pruning linear_layer_4::weight of size=torch.Size([8, 40]) and type=torch.float32 for sparsity
[ASP] Not sparsifying linear_layer_4::bias of size=torch.Size([8]) and type=torch.float32
DENSE :: Parameter containing:
tensor([[ 0.1222, -0.0463, 0.0164, 0.0172, -0.1358, -0.0895, 0.0741, -0.0615,
-0.0256, 0.0928, -0.2023, -0.1826, 0.1216, -0.1985, 0.0406, -0.2116],
[ 0.2361, -0.0382, 0.0895, -0.0834, -0.0019, 0.2197, -0.2082, 0.1073,
-0.1462, -0.1872, 0.0945, -0.0632, 0.0973, -0.1069, -0.1552, 0.2364],
[-0.1196, -0.2404, 0.1832, 0.0344, 0.0861, -0.1281, 0.0638, -0.0233,
-0.2110, -0.0232, 0.1670, -0.2404, -0.0601, -0.1872, 0.0916, 0.1083],
[-0.0452, -0.0295, 0.0596, 0.1193, 0.0482, 0.2073, -0.1630, 0.1234,
0.0278, 0.0540, 0.0715, -0.1246, -0.1181, 0.1712, 0.0818, -0.0088],
[ 0.1205, 0.0664, -0.1092, -0.1594, -0.2008, -0.1304, 0.1475, -0.0164,
0.0213, 0.1047, 0.1541, -0.1419, 0.0775, 0.1876, -0.1830, -0.1327],
[ 0.1045, -0.0542, -0.0595, -0.1135, -0.1714, 0.1132, 0.1189, 0.1599,
-0.2103, 0.1869, 0.0972, 0.2190, -0.0531, -0.0761, -0.0262, 0.2070],
[ 0.2487, -0.2104, 0.2315, -0.0325, -0.1127, -0.2104, 0.0055, 0.1607,
0.1810, 0.2007, -0.0271, 0.1910, -0.0212, 0.1520, 0.2297, 0.1531],
[ 0.1124, -0.2058, -0.1749, 0.0250, 0.0671, 0.1656, -0.1262, 0.0973,
-0.1316, 0.0120, -0.1915, 0.1203, 0.2231, -0.0278, -0.1218, 0.0111],
[ 0.0420, -0.0042, -0.1760, 0.1653, -0.1718, -0.1506, 0.1019, -0.0425,
-0.2286, 0.1699, -0.1905, -0.0009, -0.1501, 0.1786, 0.1057, -0.2300],
[ 0.1706, -0.0721, 0.2461, 0.1934, -0.1504, -0.1141, -0.0085, 0.0727,
-0.1716, 0.0454, 0.0697, 0.0826, -0.1005, -0.1638, -0.2284, 0.1794],
[-0.1038, -0.0070, -0.1411, 0.0986, 0.1945, -0.1242, 0.2205, 0.0615,
-0.2402, -0.1314, -0.1439, -0.2208, -0.1204, 0.2097, -0.2251, -0.0960],
[ 0.1185, 0.0929, 0.2295, 0.0609, 0.0005, -0.2444, 0.2029, -0.0248,
-0.0782, 0.0801, -0.0986, 0.1003, 0.0407, -0.0227, -0.2066, 0.1984],
[-0.1193, -0.1123, 0.0694, 0.2435, -0.0943, -0.0004, 0.2310, -0.1105,
-0.0937, -0.1683, 0.2232, 0.1239, -0.0198, 0.1898, 0.0292, -0.0866],
[-0.0340, -0.1764, -0.2207, 0.1107, 0.1615, 0.0726, 0.0704, 0.0465,
0.1909, -0.0753, 0.1017, 0.1398, -0.2250, -0.0883, -0.1768, 0.1065],
[ 0.0699, 0.0221, -0.0706, -0.2422, 0.0064, 0.1475, -0.1391, 0.2498,
-0.1630, 0.2277, -0.1174, 0.1665, 0.0742, -0.2086, 0.2090, -0.2427],
[-0.0431, -0.1970, 0.2308, 0.2468, -0.0647, -0.0825, 0.1532, -0.0639,
0.2454, -0.0692, 0.1116, -0.1570, -0.1846, 0.1643, 0.0245, -0.1517],
[-0.1611, -0.0807, 0.0185, -0.0967, 0.0642, 0.1849, 0.0542, 0.1773,
0.0720, 0.2302, 0.1842, 0.2347, 0.2453, 0.0601, 0.2246, 0.0600],
[ 0.0506, -0.0062, 0.2136, -0.1472, 0.0474, 0.1720, -0.2166, -0.1023,
0.0286, -0.2247, -0.0692, -0.1474, -0.0797, 0.0554, 0.0772, 0.0362],
[-0.0922, -0.1043, 0.1541, -0.0688, 0.0133, 0.1692, -0.2264, -0.1089,
-0.2046, -0.1748, 0.0176, -0.2257, -0.0861, 0.0885, 0.0235, -0.1060],
[ 0.1826, -0.0191, 0.2145, -0.1630, -0.1689, -0.1793, 0.1635, -0.1862,
-0.2051, -0.0259, -0.1466, -0.1874, 0.0689, -0.1275, -0.0155, 0.2459],
[-0.0072, -0.0006, -0.1178, 0.0383, -0.0863, -0.1586, 0.0750, -0.2482,
-0.1468, 0.1618, 0.1826, 0.1895, -0.2176, 0.0317, 0.1641, 0.2043],
[ 0.0873, -0.1241, 0.2081, 0.1279, -0.0192, -0.0306, -0.0086, 0.0890,
0.0021, -0.0608, 0.0382, -0.1968, 0.1014, 0.0488, 0.0484, 0.1428],
[-0.0581, 0.1541, -0.0946, 0.1346, 0.0747, 0.2317, -0.1318, 0.0993,
0.1210, 0.2342, -0.0406, -0.0615, -0.1087, 0.2170, 0.1927, 0.0743],
[-0.1474, -0.0023, -0.0835, 0.0987, 0.2034, -0.1102, 0.0432, -0.0455,
0.2459, 0.0598, -0.0018, 0.0548, 0.0188, 0.0726, 0.1163, -0.0023],
[-0.2150, 0.1928, 0.1251, -0.1899, -0.2301, 0.1691, -0.1877, -0.2447,
-0.0304, 0.2290, -0.1636, 0.2226, -0.1603, 0.1353, -0.1286, -0.0007],
[ 0.2425, 0.1885, -0.0435, 0.1008, 0.0793, 0.2083, 0.2023, 0.2169,
-0.2277, 0.0576, 0.0466, -0.2305, 0.0790, -0.1045, 0.0320, -0.1859],
[-0.0111, -0.1242, 0.0265, 0.0238, -0.2151, -0.1272, -0.0404, -0.1733,
0.2121, -0.0116, -0.1860, 0.1779, -0.1839, -0.0780, -0.0393, 0.1743],
[ 0.0347, 0.1931, -0.2094, -0.2481, 0.0261, 0.0725, 0.1419, -0.1574,
-0.0359, -0.0919, -0.0269, 0.2446, 0.0829, -0.1881, 0.0837, 0.2366],
[ 0.2479, 0.1270, 0.0770, 0.2054, 0.0060, 0.1961, 0.0048, 0.0444,
-0.0170, -0.0560, -0.0634, -0.1033, -0.0186, 0.0374, 0.1470, -0.1068],
[-0.2482, -0.1497, 0.0925, -0.2072, -0.1614, -0.2025, -0.0605, -0.1155,
0.0566, 0.0577, 0.0512, -0.1153, 0.1550, 0.1316, -0.0362, -0.0663],
[ 0.2236, -0.1109, -0.1035, -0.1663, -0.0725, -0.1136, 0.2306, 0.0993,
0.2031, 0.1093, -0.1292, -0.0944, -0.0546, 0.0450, 0.2294, -0.1923],
[ 0.1868, 0.1230, -0.0388, -0.1630, 0.2014, -0.0195, -0.0881, 0.0415,
-0.0256, 0.2480, 0.0842, -0.0352, 0.0946, -0.1786, 0.1457, -0.0955],
[ 0.2250, 0.0553, 0.2443, -0.1941, 0.0366, -0.2363, 0.1197, 0.2462,
-0.0461, 0.1613, 0.0554, -0.1455, 0.2356, -0.0966, -0.0748, -0.2227],
[-0.1050, 0.0643, -0.1380, 0.1334, -0.0565, -0.0957, 0.1744, -0.1140,
0.1179, -0.1452, -0.0742, 0.2178, 0.1255, -0.1313, -0.1042, 0.2297],
[ 0.2023, -0.1300, -0.0399, 0.1812, -0.1799, -0.0817, -0.2322, -0.2156,
0.1559, 0.0008, -0.2282, -0.1271, -0.1283, 0.0372, 0.0579, 0.1227],
[-0.2426, -0.2400, 0.0601, 0.1002, 0.2168, -0.0236, 0.0036, 0.2130,
0.1042, -0.0571, -0.0849, -0.2283, -0.1060, 0.0209, 0.2022, -0.1705],
[ 0.2192, 0.1337, 0.1453, -0.0817, -0.0530, -0.1809, 0.1842, -0.0266,
0.1855, -0.0075, -0.0661, -0.0262, 0.2317, -0.0970, 0.0686, -0.0887],
[ 0.1449, 0.2237, 0.2360, 0.2111, 0.0665, 0.1927, -0.0640, -0.2359,
-0.0131, -0.2311, 0.0861, -0.2288, 0.1606, -0.0152, 0.1252, 0.1348],
[ 0.1267, 0.0469, -0.2339, 0.1730, -0.0560, -0.1504, 0.0759, 0.1818,
0.0060, 0.2148, -0.0909, 0.0419, -0.2042, -0.2276, 0.0663, -0.1352],
[ 0.2479, -0.2412, 0.0483, 0.0115, -0.0927, -0.1580, 0.2320, 0.0951,
-0.2338, 0.1443, 0.2427, -0.2286, 0.0055, 0.1691, -0.2429, -0.0804]],
device='cuda:0', requires_grad=True)
Traceback (most recent call last):
File "toy_problem.py", line 87, in
PyTorch version: 1.11.0 Is debug build: False CUDA used to build PyTorch: 10.2 ROCM used to build PyTorch: N/A
OS: Ubuntu 18.04.4 LTS (x86_64) GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final) CMake version: Could not collect Libc version: glibc-2.17
Python version: 3.7.13 (default, Mar 29 2022, 02:18:16) [GCC 7.5.0] (64-bit runtime) Python platform: Linux-5.4.0-42-generic-x86_64-with-debian-buster-sid Is CUDA available: True CUDA runtime version: 10.2.89 GPU models and configuration: GPU 0: GeForce GT 710 GPU 1: GeForce GTX 1080 Ti GPU 2: GeForce GTX 1080 Ti GPU 3: GeForce GTX 1080 Ti GPU 4: GeForce GTX 1080 Ti
Nvidia driver version: 450.57 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A
Versions of relevant libraries: [pip3] numpy==1.21.5 [pip3] torch==1.11.0 [pip3] torchaudio==0.11.0 [pip3] torchvision==0.12.0 [conda] blas 1.0 mkl defaults [conda] cudatoolkit 10.2.89 hfd86e86_1 defaults [conda] ffmpeg 4.3 hf484d3e_0 pytorch [conda] mkl 2021.4.0 h06a4308_640 defaults [conda] mkl-service 2.4.0 py37h7f8727e_0 defaults [conda] mkl_fft 1.3.1 py37hd3c417c_0 defaults [conda] mkl_random 1.2.2 py37h51133e4_0 defaults [conda] numpy 1.21.5 py37h6c91a56_3 defaults [conda] numpy-base 1.21.5 py37ha15fc14_3 defaults [conda] pytorch 1.11.0 py3.7_cuda10.2_cudnn7.6.5_0 pytorch [conda] pytorch-mutex 1.0 cuda pytorch [conda] torchaudio 0.11.0 py37_cu102 pytorch [conda] torchvision 0.12.0 py37_cu102 pytorch
For asp you would need an Ampere GPU, which would explain the issue.
From the docs:
The following approach serves as a guiding example on how to generate a pruned model that can use Sparse Tensor Cores in the NVIDIA Ampere Architecture.
Closing as you are using a Pascal GPU.