#include <torch/script.h> // One-stop header.
#include <iostream>
#include <memory>
int main() {
torch::Device device(torch::kCUDA, 0);
try {
// Deserialize the ScriptModule from a file using torch::jit::load().
const std::string model_path = "yolov8s.torchscript";
torch::jit::script::Module module = torch::jit::load(model_path, torch::kCPU); << 여기서 에러발생
std::cout << "Model loaded successfully\n";
}
catch (const c10::Error& e) {
std::cerr << "Error loading the model\n";
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
간단하게 모델만 로드하는 경우인데도 load 부분에서 memory location 에러가 발생하는 경우, 다운로드받은 libtorch 파일과 코드 실행 환경의 빌드 모드 (debug / release) 가 일치하는지 먼저 확인