Closed camenduru closed 6 months ago
Hello @camenduru, thanks for the issue.
This error is because the GELU function in the old version of pytorch does not have the parameter ‘approximate’. There are two ways can fix it:
You can try lowering the version of pytorch to around 1.7.
You can replace the GELU function which is at 'anconda/envs/SlimSAM/lib/python3.8/site-packages/torch/nn/modules/activation.py' as following function.
class GELU(Module):
r"""Applies the Gaussian Error Linear Units function:
.. math:: \text{GELU}(x) = x * \Phi(x)
where :math:`\Phi(x)` is the Cumulative Distribution Function for Gaussian Distribution.
Shape:
- Input: :math:`(N, *)` where `*` means, any number of additional
dimensions
- Output: :math:`(N, *)`, same shape as the input
.. image:: ../scripts/activation_images/GELU.png
Examples::
>>> m = nn.GELU()
>>> input = torch.randn(2)
>>> output = m(input)
"""
def forward(self, input: Tensor) -> Tensor:
return F.gelu(input)
Thanks!
Thanks ❤ solved 🎉
sed -i 's/input, approximate=self.approximate/input/g' /usr/local/lib/python3.10/dist-packages/torch/nn/modules/activation.py
I made a colab. 🥳 I hope you like it. https://github.com/camenduru/SlimSAM-colab
Hi 👋 thanks for the project ❤ I got an error when I tried running
inference.py
(torch 2.1.0+cu118)Is there a way to fix it?