Skip to content

export_sam_model on Windows not working; RuntimeError: "upsample_bilinear2d_out_frame" not implemented for 'Byte' #1104

@maartenpaul

Description

@maartenpaul

Describe the bug
When attempting to export a fine-tuned micro-sam model to the BioImage.IO format using the export_sam_model function on Windows 10, a RuntimeError is raised. This appears to be due to a missing pre-compiled kernel in the PyTorch Windows build for a specific upsampling operation on 'Byte' (uint8) data types. The process works as expected on Linux.

To Reproduce

  1. Set up a micro-sam environment on Windows 10 using conda from conda-forge.
  2. Install micro-sam version 1.6.1 and a recent PyTorch build (e.g., 2.7.1 with CUDA).
  3. Execute a script that calls the export_sam_model function with a uint8 image as input.

Error Log

The script fails with the following RuntimeError:

...
File ...\site-packages\torch\nn\functional.py:4678, in interpolate(input, size, scale_factor, mode, align_corners, recompute_scale_factor, antialias)
    4676 assert align_corners is not None
    4677 if antialias:
-> 4678     return torch._C._nn._upsample_bilinear2d_aa(
    4679         input, output_size, align_corners, scale_factors
    4680     )
...
RuntimeError: "upsample_bilinear2d_out_frame" not implemented for 'Byte'

Workaround

I have confirmed that the same script runs without any issues in a Linux environment (WSL Ubuntu) with a comparable PyTorch version. This suggests the necessary kernel for this operation is available in the Linux PyTorch builds but not in the Windows ones. I thought it will be useful report in case somebody hits into the same issue.

Environment

  • OS: Windows 10
  • pytorch version: 2.7.1 (installed via conda from conda-forge)
  • micro-sam version: 1.6.1
  • GPU: NVIDIA GeForce RTX 5090
  • CUDA version: 12.9

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