pytorch找不到模块 [英] Pytorch could not find module

查看:1411
本文介绍了pytorch找不到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下命令安装了pytorch:

I have installed pytorch with command:

conda install pytorch torchvision cudatoolkit=10.2 -c pytorch -y

Python抱怨带有消息的行导入割炬:

Python complains regarding line import torch with message:

Could not find module 'C:\ProgramData\Anaconda3\envs\edx\lib\site-packages\torch\lib\caffe2_nvrtc.dll' (or one of its dependencies). Try using the full path with constructor syntax

的完整路径。该目录包含库caffe2_nvrtc.dll。

This directory contains library caffe2_nvrtc.dll. What might be wrong and how to fix this error?

推荐答案

我遇到了同样的问题。如果您的操作系统是Windows,则建议您使用Anaconda并在单独的conda环境中安装pytorch。快速解决方案是在Google上搜索nvcuda.dll文件并下载该文件。如果您在Jupyter笔记本电脑上运行代码,则输出将为您提供conda环境的 lib文件夹的完整路径。默认情况下为 C:CUsers\YourUserName\anaconda3\envs\mera_beta\Lib\site-packages\torch\lib。转到此目录,然后将文件粘贴到此文件夹中。重新运行您的代码。希望它将运行。

I faced the same problem. If your OS is Windows then I would recommend using Anaconda and installing pytorch in separate conda environment. Quick solution is to search for nvcuda.dll file on google and download this file. If you are running the code on Jupyter notebook the output will give you the complete path of the 'lib' folder of conda environment. By default it is 'C:\Users\YourUserName\anaconda3\envs\mera_beta\Lib\site-packages\torch\lib'. Go this directory and paste the file in this folder. Rerun your code. Hopefully it will run.

这篇关于pytorch找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆