使用 tokenizers 库编译时,遇到静态 libcpmt.lib 和动态 msvcprt.lib 冲突链接错误。 我的程序使用分词器 0.15.0 和 tch-rs 0.14.0 ,如下所示:
use anyhow::Result;
use tokenizers::Tokenizer;
use tch;
fn main() -> Result<()> {
//load model
let model_file = "anyhow_to_the_model_path";
let model =tch::CModule::load(model_file)?;
println!("model loaded");
Ok(())
}
货物报告:“错误:与
link.exe
链接失败:退出代码:1169”
=注意:libtorch_sys-14beaa7f5e22ac1d.rlib(torch_api.o):错误LNK2038:检测“RuntimeLibrary”非匹配值“MD_DynamicRelease”非匹配值“MT_StaticRelease”(libesaxx_rs-0ddd131668a89c52.rlib(esaxx.o))。
我想知道如何修复这个错误。我的依赖项是 torch-rs 0.14 和 tokenziers 0.15。
我尝试设置环境:LIBTORCH_STATIC=1,但失败了。
我的货物.toml:
[package]
name = "ts-infer"
version = "0.1.0"
edition = "2021"
publish = ["rsproxy"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tch = "0.14.0"
anyhow = "1.0"
tokenizers = "0.15.1"
和 rustup 显示:
stable-x86_64-pc-windows-msvc (default)
rustc 1.75.0 (82e1608df 2023-12-21)
还有更多:
标记器包cargo.toml: https://github.com/huggingface/tokenizers/blob/main/tokenizers/Cargo.toml
tch-rs Cargo.toml: https://github.com/LaurentMazare/tch-rs/blob/main/Cargo.toml
我发现问题了。分词器包含的 esaxx-rs 软件包使用指向 crt 的静态链接。我修改了esaxx-rs的build.rs并删除了静态链接代码