pytorch错误: 找不到指定的模块 Error loading “torch_python.dll“ or one of its dependencies

省流:python(3.12.7) 和 pytorch(2.4.0)版本不配套

问题

起因是看到了这本书《Build a Large Language Model (From Scratch) 》,是2024年9月新出的, 作者  Sebastian Raschka,想要按照作者给出的步骤来手搓一个大语言模型,以便后面拿出来吹牛。

作者在书中写道:

Therefore, when installing PyTorch, it’s advisable to use a version of Python that is one or two releases older. For instance, if the latest version of Python is 3.13, using Python 3.11 or 3.12 is recommended.

。。。。

I use PyTorch 2.4.0 for the examples, so I recommend that you use the following command to install the exact version to guarantee compatibility with this book:

pip install torch==2.4.0

为了防止和作者环境不一致,遇到一堆奇怪的问题,需要安装pytorch的2.4.0版本,但作者坑就坑在这里,没说自己用的哪个python版本,只是推荐3.11和3.12。

秉着[装新不装旧]的原则,上python官网找了个 3.12.7版本(win10 64位)来安装。然后用pip安装pytorch 2.4.0。看起来很顺利,但用起来就出问题了:

【OSError: [WinError 126] 找不到指定的模块。 Error loading "D:\Python3127\Lib\site-packages\torch\lib\torch_python.dll" or one of its dependencies.】


C:\>python
Python 3.12.7 (tags/v3.12.7:0b05ead, Oct  1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceba
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值