ckkelvinchan / BasicVSR_PlusPlus

Official repository of "BasicVSR++: Improving Video Super-Resolution with Enhanced Propagation and Alignment"
Apache License 2.0
568 stars 63 forks source link

I used demo to run my own video file in linux environment. After a period of time, the process running demo was killed #20

Closed Dylan-Jinx closed 5 months ago

Dylan-Jinx commented 1 year ago

My Enviorment: PyTorch 1.11.0 Python 3.8(ubuntu20.04) Cuda 11.3 GPU:RTX A5000 * 1;video memory:24GB CPU:14core Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz ram:30GB system disk:20 GB data disk:50GB SSD While running the demo based on the basicvsr_plusplus_reds4.pth checkpoint, I put in a blurry video of myself for several tens of seconds, and after a while the process was killed. I tried to set -- max-seq-len=1 but still the process was killed.How can I solve this problem?

huhai463127310 commented 1 year ago

I meet the same issue

My Enviorment: PyTorch 1.11.0 Python 3.8(ubuntu20.04) Cuda 11.3 GPU:RTX A5000 * 1;video memory:24GB CPU:14core Intel(R) Xeon(R) Gold 6330 CPU @ 2.00GHz ram:30GB system disk:20 GB data disk:50GB SSD While running the demo based on the basicvsr_plusplus_reds4.pth checkpoint, I put in a blurry video of myself for several tens of seconds, and after a while the process was killed. I tried to set -- max-seq-len=1 but still the process was killed.How can I solve this problem?

Dylan-Jinx commented 1 year ago

@huhai463127310 I solve this problem. I think you can try to use a test video for three or four seconds. When I use minimal video to input this demo can success run.If you have any other questions, you can email me or leave your email.

CarlGao4 commented 1 year ago

I found the issue that caused this problem. The demo will read the whole video into memory, and extract all the frames into array, which consumes laaaaarge amount of memory. I tried to fix it, and you can view it here: https://github.com/CarlGao4/BasicVSR_PlusPlus/blob/master/demo/restoration_large_video_demo.py Currently, input can only be a video file, output supports frames or stdout

Dylan-Jinx commented 1 year ago

@CarlGao4 ,hello,have you solve the read all frame of video in memory problem?and can you tell me the way to solve this problem as if you solved or have idea

CarlGao4 commented 1 year ago

@CarlGao4 ,hello,have you solve the read all frame of video in memory problem?and can you tell me the way to solve this problem as if you solved or have idea

Just download this file and simply run the same command you used to process your video, replacing restoration_video_demo.py with restoration_large_video_demo.py. Please remember that this script only accept video input and picture sequence output.

izeroo commented 6 months ago

@CarlGao4 ,hello,have you solve the read all frame of video in memory problem?and can you tell me the way to solve this problem as if you solved or have idea

Just download this file and simply run the same command you used to process your video, replacing restoration_video_demo.py with restoration_large_video_demo.py. Please remember that this script only accept video input and picture sequence output.

16GB RAM and 6GB VRAM, still not enough for a 1.7GB one-hour long 1080p video... I see GPU usage reached 100% first. But after a few second it have reached OOM.

load checkpoint from local path: chkpts/basicvsr_plusplus_reds4.pth
input image size: (1920, 1080)
  0%|                                                                                    | 0/215834 [00:25<?, ?frame/s]
Traceback (most recent call last):
  File "BasicVSR_PlusPlus\demo\restoration_large_video_demo.py", line 104, in <module>
    main()
  File "BasicVSR_PlusPlus\demo\restoration_large_video_demo.py", line 92, in main
    res = model(lq=data_chunk.to(device), test_mode=True)["output"].cpu()
  File "anaconda3\envs\basicvsrplusplus\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "anaconda3\envs\basicvsrplusplus\lib\site-packages\mmcv\runner\fp16_utils.py", line 116, in new_func
    return old_func(*args, **kwargs)
  File "basicvsr_plusplus\mmedit\models\restorers\basic_restorer.py", line 75, in forward
    return self.forward_test(lq, gt, **kwargs)
  File "basicvsr_plusplus\mmedit\models\restorers\basicvsr.py", line 175, in forward_test
    output = self.generator(lq)
  File "anaconda3\envs\basicvsrplusplus\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "basicvsr_plusplus\mmedit\models\backbones\sr_backbones\basicvsr_pp.py", line 353, in forward
    return self.upsample(lqs, feats)
  File "basicvsr_plusplus\mmedit\models\backbones\sr_backbones\basicvsr_pp.py", line 269, in upsample
    hr = self.lrelu(self.upsample2(hr))
  File "anaconda3\envs\basicvsrplusplus\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "basicvsr_plusplus\mmedit\models\common\upsample.py", line 50, in forward
    x = F.pixel_shuffle(x, self.scale_factor)
RuntimeError: CUDA out of memory. Tried to allocate 7.91 GiB (GPU 0; 6.00 GiB total capacity; 10.46 GiB already allocated; 0 bytes free; 10.96 GiB reserved in total by PyTorch)
CarlGao4 commented 6 months ago

You can try reducing --max-seq-len. I remembered that I could run it with only 4GiB to scale up 1080p when it is set to 1 (though it may reduce quality)

pingxingxianpaixingxing commented 6 months ago

@CarlGao4 ,hello,have you solve the read all frame of video in memory problem?and can you tell me the way to solve this problem as if you solved or have idea

Just download this file and simply run the same command you used to process your video, replacing restoration_video_demo.py with restoration_large_video_demo.py. Please remember that this script only accept video input and picture sequence output.

Hello, I encountered this problem while using your file. Why is this? 屏幕截图 2023-12-22 172256

CarlGao4 commented 6 months ago

Maybe try upgrading Python to 3.9? Please also remember to install torch<=2.0.1 and mmcv-full<=1.6.0

pingxingxianpaixingxing commented 6 months ago

Maybe try upgrading Python to 3.9? Please also remember to install torch<=2.0.1 and mmcv-full<=1.6.0

Thank you, after upgrading Python to 3.9, it can run, but the running speed is very slow, processing about one frame per second, is this normal? 屏幕截图 2023-12-22 203351

CarlGao4 commented 6 months ago

Yes, it's about 1frame/s running on 4060 when enlarging 540p videos

izeroo commented 6 months ago

You can try reducing --max-seq-len. I remembered that I could run it with only 4GiB to scale up 1080p when it is set to 1 (though it may reduce quality)

Well I've tried to add--max-seq-len 1 , which produced the result above. So my poor 2060 with 6GB VRAM maybe just can't handle it

CarlGao4 commented 6 months ago

Maybe you can try the 2x model?

lcc157 commented 5 months ago

Maybe you can try the 2x model?

Do you have the 2x model?

P1nkm2n commented 5 months ago

Maybe try upgrading Python to 3.9? Please also remember to install torch<=2.0.1 and mmcv-full<=1.6.0

Thank you, after upgrading Python to 3.9, it can run, but the running speed is very slow, processing about one frame per second, is this normal? 屏幕截图 2023-12-22 203351

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

P1nkm2n commented 5 months ago

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

pingxingxianpaixingxing commented 5 months ago

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

My CUDA version is 11.3

CarlGao4 commented 5 months ago

You should use the same CUDA version as PyTorch

P1nkm2n commented 5 months ago

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

My CUDA version is 11.3

I've tried, then I can't install mmcv-full under 1.6.0, don't know why

pingxingxianpaixingxing commented 5 months ago

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

My CUDA version is 11.3

I've tried, then I can't install mmcv-full under 1.6.0, don't know why

What does your error look like?

pingxingxianpaixingxing commented 5 months ago

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

What version of the CUDA toolkit are you using? When the version is too high, it may prevent the installation of a lower version of 'mmcv-full,' and when the version is too low, it may result in the following error:RuntimeError: CUDA error: invalid device function;Segmentation fault (core dumped)

My CUDA version is 11.3

I've tried, then I can't install mmcv-full under 1.6.0, don't know why

What does your error look like?

You can refer to the official documentation of mmedit or mmagic to download, that’s how I did it.

txy00001 commented 5 months ago

I added the large file to the latest mmagic, and an error was reported after it was executed, image How do I change the code to adapt it to the latest mmagic? image

pingxingxianpaixingxing commented 5 months ago

I added the large file to the latest mmagic, and an error was reported after it was executed, image How do I change the code to adapt it to the latest mmagic? image

I did not use the latest version of mmagic. Instead, I used the mmedit (an old version of mmagic) from the source code provided by the author on GitHub. Here is the URL: https://zyhmmediting-zh.readthedocs.io/en/dev-1.x/model_zoo/%E8%A7%86%E9%A2%91%E8%B6%85%E5%88%86%E8%BE%A8%E7%8E%87.html. I used it to set up the environment and then ran it using the author’s source code.