wxian3 / NeuroLens

Code implementation of NeuroLens
MIT License
57 stars 4 forks source link

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 55.57 GiB. #3

Open SWUSTLKL opened 6 months ago

SWUSTLKL commented 6 months ago

Hello, while running your code, I used a GeForce RTX 3080 with an obj file of size 3.74MB and got the error like this:

(neural) E:\allpaper\Camera-calibration\Neural Lens Modeling\code\NeuroLens\SynLens>python import_lenses.py --input_path path_to_target

cuda is available. Traceback (most recent call last): File "E:\allpaper\Camera-calibration\Neural Lens Modeling\code\NeuroLens\SynLens\import_lenses.py", line 111, in process_mesh(lenses_data[i], lens_name, num_views, image_size, render_rgb, out_fd) File "E:\allpaper\Camera-calibration\Neural Lens Modeling\code\NeuroLens\SynLens\renderer.py", line 413, in process_mesh target_cameras, target_rgb = render_mesh(obj_filename, num_views, image_size, render_rgb, lens_model) File "E:\allpaper\Camera-calibration\Neural Lens Modeling\code\NeuroLens\SynLens\renderer.py", line 393, in render_mesh target_images = renderer(meshes, cameras=cameras, lights=lights) File "D:\anaconda\envs\neural\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "D:\anaconda\envs\neural\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "D:\anaconda\envs\neural\lib\site-packages\pytorch3d-0.7.5-py3.9-win-amd64.egg\pytorch3d\renderer\mesh\renderer.py", line 62, in forward images = self.shader(fragments, meshes_world, kwargs) File "D:\anaconda\envs\neural\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "D:\anaconda\envs\neural\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "D:\anaconda\envs\neural\lib\site-packages\pytorch3d-0.7.5-py3.9-win-amd64.egg\pytorch3d\renderer\mesh\shader.py", line 126, in forward texels = meshes.sample_textures(fragments) File "D:\anaconda\envs\neural\lib\site-packages\pytorch3d-0.7.5-py3.9-win-amd64.egg\pytorch3d\structures\meshes.py", line 1542, in sample_textures return self.textures.sample_textures( File "D:\anaconda\envs\neural\lib\site-packages\pytorch3d-0.7.5-py3.9-win-amd64.egg\pytorch3d\renderer\mesh\textures.py", line 1003, in sample_textures texels = F.grid_sample( File "D:\anaconda\envs\neural\lib\site-packages\torch\nn\functional.py", line 4304, in grid_sample return torch.grid_sampler(input, grid, mode_enum, padding_mode_enum, align_corners) torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 55.57 GiB. GPU 0 has a total capacty of 12.00 GiB of which 9.02 GiB is free. Of the allocated memory 984.52 MiB is allocated by PyTorch, and 463.48 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Is it possible that I need more than 55.57 GB of video memory because I chose an inappropriate obj file? Is there a recommended demo program suitable for 12g video memory?

SWUSTLKL commented 6 months ago

May I ask why the GPU is so large because of the model or the OBJ I use?| I'm running the piece of code that generated the dataset。 python import_lenses.py --input_path path_to_target