Open Sarthak-22 opened 5 months ago
Minimum code snippet to reproduce the error :
model = Restormer()
example_inputs = torch.randn(1, 3, 512, 512)#.to(device='cuda')
imp = tp.importance.GroupNormImportance(p=2)
# Ignore some layers, e.g., the output layer
ignored_layers = [model.output, model.refinement]
in_channel_groups = {}
for name, module in model.named_modules():
if isinstance(module, nn.Conv2d) and module.groups > 1:
in_channel_groups[name] = module.groups
# Initialize a pruner
pruner = tp.pruner.MetaPruner(
model,
example_inputs,
importance=imp,
pruning_ratio=0.5,
in_channel_groups=in_channel_groups,
out_channel_groups=in_channel_groups,
ignored_layers=ignored_layers,
)
for g in pruner.step(interactive=True): # Error faced in pruner.step()
g.prune()
Hello, may I ask if there has been any progress? I used this piece of code and encountered the following error. My environment is Ubuntu22, python3.10
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
../aten/src/ATen/native/cuda/IndexKernel.cu:92: operator(): block: [0,0,0], thread: [127,0,0] Assertion `-sizes[i] <= index && index < sizes[i] && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/IndexKernel.cu:92: operator(): block: [0,0,0], thread: [0,0,0] Assertion `-sizes[i] <= index && index < sizes[i] && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/IndexKernel.cu:92: operator(): block: [0,0,0], thread: [1,0,0] Assertion `-sizes[i] <= index && index < sizes[i] && "index out of bounds"` failed.
example_inputs = torch.randn(1, 3, 512, 512)#.to(device='cuda') imp = tp.importance.GroupNormImportance(p=2)
Ignore some layers, e.g., the output layer
ignored_layers = [model.output, model.refinement]
in_channel_groups = {} for name, module in model.named_modules(): if isinstance(module, nn.Conv2d) and module.groups > 1: in_channel_groups[name] = module.groups
Initialize a pruner
pruner = tp.pruner.MetaPruner( model, example_inputs, importance=imp, pruning_ratio=0.5, in_channel_groups=in_channel_groups, out_channel_groups=in_channel_groups, ignored_layers=ignored_layers, )
for g in pruner.step(interactive=True): # Error faced in pruner.step() g.prune()
same
I am trying to prune the Restormer model using Torch-pruning library but I stumbled upon the following error :
I observed that many people faced this issue, evidently seen in the open issues covering this topic. However, none of the workarounds seem to work for me. I believe the concat and split operation might have been an issue but these operations were fixed in the latest version of the library. The inbuilt helper modules don't seem to reduce or split the indices, specifically in the feedforward module where there is a split operation present. Any help would be appreciated !
Here is the model code: