hello,以下代码一直跑不通:
def pre_calculate(x, k, sf):
'''
Args:
x: NxCxHxW, LR input
k: NxCxhxw
sf: integer
Returns:
FB, FBC, F2B, FBFy
will be reused during iterations
'''
print("Type of x: ", type(x))
print("Type of k: ", type(k))
print("sf is: ", sf)
print("shape of x: ", x.shape)
print("shape of k: ", k.shape)
w, h = x.shape[-2:]
# Visualize x and k
visualize_tensor(x, 'Input Image (x)')
visualize_tensor(k, 'Kernel (k)', is_kernel=True)
print("type of k: ", type(k))
FB = p2o(k, (w*sf, h*sf))
# Check for NaNs or Infinities before applying torch.abs
if torch.isnan(FB).any():
raise ValueError("FB contains NaNs!")
if torch.isinf(FB).any():
raise ValueError("FB contains Infinities!")
FBC = torch.conj(FB)
print ("shape of FBC: ", FBC.shape)
print ("shape of FB: ", FB.shape)
FB = FB.to('cuda')
print("FB dtype:", FB.dtype)
print ("shape of torch.abs(FB): ",torch.abs(FB).shape)
FB_abs = torch.abs(FB)
F2B = torch.pow(torch.abs(FB), 2)
STy = upsample(x, sf=sf)
FBFy = FBC*torch.fft.fftn(STy, dim=(-2, -1))
return FB, FBC, F2B, FBFy
但是我一直在报错:
Traceback (most recent call last):
File "/export1/project/aaron.l/DPIR-master/main_dpir_sisr_real_applications_baseline.py", line 292, in <module>
main()
File "/export1/project/aaron.l/DPIR-master/main_dpir_sisr_real_applications_baseline.py", line 231, in main
FB, FBC, F2B, FBFy = sr.pre_calculate(img_L_tensor, k_tensor, sf)
File "/export1/project/aaron.l/DPIR-master/utils/utils_sisr.py", line 181, in pre_calculate
print ("shape of torch.abs(FB): ",torch.abs(FB).shape)
RuntimeError: CUDA driver error: invalid argument
Process finished with exit code 1
请问是为什么?
打印出来的结果为
```python
Type of x: <class 'torch.Tensor'>
Type of k: <class 'torch.Tensor'>
sf is: 2
shape of x: torch.Size([1, 3, 336, 504])
shape of k: torch.Size([1, 1, 17, 17])
type of k: <class 'torch.Tensor'>
shape of FBC: torch.Size([1, 1, 672, 1008])
shape of FB: torch.Size([1, 1, 672, 1008])
```