I try to build a conan package for libtorch in ubuntu 18.04, Environment is:
NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 GeForce RTX 2080
test_package.cpp:
#include <torch/cuda.h>
#include <iostream>
int main(void) {
std::cout << "CUDA DEVICE COUNT: " << torch::cuda::device_count() << std::endl;
if (torch::cuda::is_available()) {
std::cout << "CUDA is available! Training on GPU." << std::endl;
}
return 0;
}
When I test libtorch 1.10.2+cu102, it returns
libtorch/1.10.2+cu102 (test package): Running test()
CUDA DEVICE COUNT: 1
CUDA is available! Training on GPU.
But when I test libtorch 1.9.0+cu102(or libtorch 1.9.1+cu102), it returns:
libtorch/1.9.1+cu102 (test package): Running test()
CUDA DEVICE COUNT: 0
how does this happen? I can’t figure out why.