How to check libtorch version

Hi,

In Python I can get the PyTorch version string with:
print(torch.__version__)
However, I did not figure out a way to do the same with the C++ libtorch interface?

Does someone know how to retrieve the libtorch version string using the C++ interface?

Thanks!
Thomas

2 Likes

Was wondering about the same. Did you find out whether this is possible yet?

Did you figure out a way to do it? I filed a feature request for this issue:

1 Like

Starting from 1.8, one can use TORCH_VERSION_{MAJOR,MINOR,PATCH} for this.

#include <torch/torch.h>
#include <iostream>

int main() {
  std::cout << "PyTorch version: "
    << TORCH_VERSION_MAJOR << "."
    << TORCH_VERSION_MINOR << "."
    << TORCH_VERSION_PATCH << std::endl;
}

Prints:
PyTorch version: 1.8.0

2 Likes

Is it possible to also report the CUDA version the library was compiled for?