Fix OSError: libtorch_hip.so: cannot open shared object file: No such file or directory

By | April 19, 2023

When we are running a pytorch model, we may get this error: OSError: libtorch_hip.so: cannot open shared object file: No such file or directory. In this tutorial, we will introduce how to fix.

Why does this error occur?

Your torch version and torchaudio version is unmatched. This error may like:

Fix OSError libtorch_hip.so cannot open shared object file No such file or directory

How to fix this error?

You should install right torch version.

For example, our torch version is: 1.10.1

A Simple Guide to Check Torch Version Installed – PyTorch Tutorial

The right torchaudio is: 0.10.0

We can see the right correspondence between torch and torchaudio is below:

PyTorch TorchAudio Python
2.0.0 2.0.1 >=3.8<=3.11
1.13.1 0.13.1 >=3.7<=3.10
1.13.0 0.13.0 >=3.7<=3.10
1.12.1 0.12.1 >=3.7<=3.10
1.12.0 0.12.0 >=3.7<=3.10
1.11.0 0.11.0 >=3.7<=3.9
1.10.0 0.10.0 >=3.6<=3.9
1.9.1 0.9.1 >=3.6<=3.9

You can see more in this page:

https://pytorch.org/audio/main/installation.html