Skip to content

Loading donut transformers model getting error #327

@ankitagotarne

Description

@ankitagotarne

self.model = self.model.to(self.device)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 1145, in to
return self._apply(convert)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 797, in _apply
module._apply(fn)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 797, in _apply
module._apply(fn)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 797, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 820, in _apply
param_applied = fn(param)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 1143, in convert
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
RuntimeError: CUDA error: device-side assert triggered
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

code:-
class Donut:
def init(self):
try:
self.processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-docvqa")
self.model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-docvqa")
self.device = "cuda" if torch.cuda.is_available() else "cpu"
if torch.cuda.is_available():
try:
self.device = torch.device("cuda")
self.model = self.model.to(self.device)
torch.cuda.empty_cache()
except RuntimeError as e:
console_logger.warning(f"{str(e)}")

    except Exception as e:
        console_logger.error(f"Failed to initialize Donut: {str(e)}")
        raise

Versions:-
torch==2.0.1+cu118
torchaudio==2.0.2+cu118
torchvision==0.15.2+cu118
transformers==4.24.0
Nvidia Driver :- Driver Version: 550.144.03 CUDA Version: 12.4
Docker image :- nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions