Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [3, 1, 11, 11], but got 3-dimensional input of size [3, 900, 1600] instead #49

Open
yuxuanfanOrion opened this issue May 12, 2024 · 2 comments

Comments

@yuxuanfanOrion
Copy link

Hi! Thanks for your great work.

I have met some bugs when I try to train bungee dataset.

The following are the bugs. Thanks for helping!

Traceback (most recent call last):
File "/home/fanyx2311/.conda/envs/sgs/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/fanyx2311/.conda/envs/sgs/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/main.py", line 39, in
cli.main()
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/server/cli.py", line 430, in main
run()
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/fanyx2311/.local/lib/python3.8/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "train.py", line 527, in
training(lp.extract(args), op.extract(args), pp.extract(args), dataset, args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from, wandb, logger)
File "train.py", line 143, in training
ssim_loss = (1.0 - ssim(image, gt_image))
File "/data20_ssd/fanyx2311/Scaffold-GS/utils/loss_utils.py", line 41, in ssim
return _ssim(img1, img2, window, window_size, channel, size_average)
File "/data20_ssd/fanyx2311/Scaffold-GS/utils/loss_utils.py", line 44, in _ssim
mu1 = F.conv2d(img1, window, padding=window_size // 2, groups=channel)
RuntimeError: Expected 4-dimensional input for 4-dimensional weight [3, 1, 11, 11], but got 3-dimensional input of size [3, 900, 1600] instead
Training progress: 0%|

@farewellwho
Copy link

I've got the same exception. Did you solve the problem?

@farewellwho
Copy link

farewellwho commented Nov 5, 2024

I've got the same exception. Did you solve the problem?

This problem happened because I was using the wrong versions. My cuda toolkit version was 11.1, and torch related version were torch==1.10.2+cu111, torchvision==0.11.3+cu111 and torchaudio==0.10.2+cu11. You can modify the code of _ssim(...) function by inserting the following two lines at the beginning to solve this problem, but other problems will be encountered (in my case it is this one).

img1 = img1.unsqueeze(0)
img2 = img2.unsqueeze(0)

So the final solution should be using the correct versions. When I upgrade my cuda toolkit to 11.4 and recreate the conda env using
conda env create --file ./environment.yml,
everything is ok now.
By the way, my system info is as following:

 ~  nvidia-smi
Tue Nov  5 10:26:21 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.182.03   Driver Version: 470.182.03   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:65:00.0 Off |                  N/A |
| 30%   34C    P8    13W / 320W |   5648MiB / 10009MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      7696      C   ...vs/scaffold_gs/bin/python     5461MiB |
|    0   N/A  N/A      7837      G   /usr/lib/xorg/Xorg                 18MiB |
|    0   N/A  N/A     10021      G   /usr/bin/gnome-shell               15MiB |
|    0   N/A  N/A     27031      G   /usr/lib/xorg/Xorg                112MiB |
|    0   N/A  N/A     27160      G   /usr/bin/gnome-shell               34MiB |
+-----------------------------------------------------------------------------+
 ~
 ~  nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_Oct_11_21:27:02_PDT_2021
Cuda compilation tools, release 11.4, V11.4.152
Build cuda_11.4.r11.4/compiler.30521435_0
 ~
 ~ conda list | grep torch
ffmpeg                    4.3                  hf484d3e_0    pytorch
pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytorch-scatter           2.1.0           py37_torch_1.12.0_cu116    pyg
torchaudio                0.12.1               py37_cu116    pytorch
torchvision               0.13.1               py37_cu116    pytorch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants