When running torch.inverse() or torch.linalg.inv() when running the matrix inversion code, an error is reported:
RuntimeError: Error in dlopen: libnvJitLink.so.12: cannot open shared object file: No such file or directory
The reason is that the libnvJitLink.so.12 library is not installed, and the installation link
still shows an error after the installation is complete.
RuntimeError: cusolver error: CUSOLVER_STATUS_NOT_INITIALIZED, when calling `cusolverDnCreate(handle)`
I can't find the corresponding solution on the Internet, and it is not a problem of insufficient GPU memory, so I choose to use cpu for calculation, and then put it on cuda.
# 函数运行测试
import torch
import numpy as np
device = torch.device("cuda:6" if torch.cuda.is_available() else "cpu")
print(device)
a = np.array([[[ 2.7734e+03, 0.0000e+00, -1.0740e+03, -4.5573e+06],[ 0.0000e+00, -2.7734e+03, -4.2000e+02, 9.9102e+05],[ 0.0000e+00, 0.0000e+00, -1.0000e+00, 1.2700e+03],[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 1.0000e+00]]])
print(a)
a = torch.from_numpy(a)
print(a)
a_gpu = a.to(device)
print(a_gpu)
a_inv_cpu = torch.inverse(a) # 在cpu上torch.inverse()可以正常运行
print(a_inv_cpu)
a_inv_gpu = torch.inverse(a_gpu.to('cpu')).to(device) #先放到cpu上计算,完成后再放到gpu上参与下一步深度学习
#a_inv_gpu = torch.inverse(a_gpu)
print(a_inv_gpu)