【rust】《处理报错Cannot find a libtorch install, you can either:》
在学习rust的tch-rs框架的时候,引入依赖并运行小demo的时候报错了;错误信息如下:
报错信息
Cannot find a libtorch install, you can either:
- Install libtorch manually and set the LIBTORCH environment variable to appropriate path.
- Use a system wide install in /usr/lib/libtorch.so.
- Use a Python environment with PyTorch installed by setting LIBTORCH_USE_PYTORCH=1
解决方式
没别的说的,下载libtorch包
新版本下载地址:https://pytorch.org/get-started/locally/
旧版本下载地址:https://download.pytorch.org/libtorch/cpu/
这里我下载的是1.11.0的cpu版本

解压压缩包,文件夹名称要英文不能有空格,否则可能识别不到

配置环境变量


在试试运行Rust项目就可以了,然后就出现新的报错了。