简体   繁体   English

为 pytorch 安装预训练模型时出错

[英]Error installing pretrained models for pytorch

I'm working on a Windows 10 machine (yes, I know, don't laugh,).我正在使用 Windows 10 机器(是的,我知道,别笑,)。 and with python 3,7: and I'm trying to install the pretrained models here:并使用 python 3,7: 我正在尝试在此处安装预训练模型:

https://github.com/meliketoy/fine-tuning.pytorch https://github.com/meliketoy/fine-tuning.pytorch

The commands that the website suggests are:该网站建议的命令是:

$ git clone https://github.com/Cadene/pretrained-models.pytorch.git
$ pretrained-models.pytorch
$ python setup.py install

Although the website says this is for Python 3.5, and I have 3.7, I think the 3.7 version should be back-compatible, right?虽然网站上说这是针对 Python 3.5,而我有 3.7,但我认为 3.7 版本应该是向后兼容的,对吧?

I successfully ran the git clone , and the pretrained-models.pytorch was actually a cd command (which threw me for a loop for a second.).我成功运行了git clone ,而pretrained-models.pytorch实际上是一个cd命令(这让我陷入了一个循环。)。 Then I ran into trouble with python setup.py install然后我遇到了python setup.py install的麻烦

The error I'm getting is:我得到的错误是:

[Errno 2] No such file or directory: 'build\\bdist.win-amd64\\egg\\pretrainedmodels\\models\\resnext_features\\__pycache__\\resnext101_32x4d_features.cpython-37.pyc.1702181039952'

How can I fix this error?我该如何解决这个错误?

EDIT (in response to a comment): Someone asked for the full traceback.编辑(回应评论):有人要求完整的追溯。 Here it is!这里是!

(base) G:\>python setup.py install
running install
running bdist_egg
running egg_info
creating pretrainedmodels.egg-info
writing pretrainedmodels.egg-info\PKG-INFO
writing dependency_links to pretrainedmodels.egg-info\dependency_links.txt
writing requirements to pretrainedmodels.egg-info\requires.txt
writing top-level names to pretrainedmodels.egg-info\top_level.txt
writing manifest file 'pretrainedmodels.egg-info\SOURCES.txt'
reading manifest file 'pretrainedmodels.egg-info\SOURCES.txt'
writing manifest file 'pretrainedmodels.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\pretrainedmodels
copying pretrainedmodels\utils.py -> build\lib\pretrainedmodels
copying pretrainedmodels\version.py -> build\lib\pretrainedmodels
copying pretrainedmodels\__init__.py -> build\lib\pretrainedmodels
creating build\lib\pretrainedmodels\datasets
copying pretrainedmodels\datasets\utils.py -> build\lib\pretrainedmodels\datasets
copying pretrainedmodels\datasets\voc.py -> build\lib\pretrainedmodels\datasets
copying pretrainedmodels\datasets\__init__.py -> build\lib\pretrainedmodels\datasets
creating build\lib\pretrainedmodels\models
copying pretrainedmodels\models\bninception.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\cafferesnet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\dpn.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\fbresnet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\inceptionresnetv2.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\inceptionv4.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\nasnet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\nasnet_mobile.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\pnasnet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\polynet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\resnext.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\senet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\torchvision_models.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\utils.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\vggm.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\wideresnet.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\xception.py -> build\lib\pretrainedmodels\models
copying pretrainedmodels\models\__init__.py -> build\lib\pretrainedmodels\models
creating build\lib\pretrainedmodels\models\resnext_features
copying pretrainedmodels\models\resnext_features\resnext101_32x4d_features.py -> build\lib\pretrainedmodels\models\resnext_features
copying pretrainedmodels\models\resnext_features\resnext101_64x4d_features.py -> build\lib\pretrainedmodels\models\resnext_features
copying pretrainedmodels\models\resnext_features\__init__.py -> build\lib\pretrainedmodels\models\resnext_features
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\pretrainedmodels
creating build\bdist.win-amd64\egg\pretrainedmodels\datasets
copying build\lib\pretrainedmodels\datasets\utils.py -> build\bdist.win-amd64\egg\pretrainedmodels\datasets
copying build\lib\pretrainedmodels\datasets\voc.py -> build\bdist.win-amd64\egg\pretrainedmodels\datasets
copying build\lib\pretrainedmodels\datasets\__init__.py -> build\bdist.win-amd64\egg\pretrainedmodels\datasets
creating build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\bninception.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\cafferesnet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\dpn.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\fbresnet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\inceptionresnetv2.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\inceptionv4.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\nasnet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\nasnet_mobile.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\pnasnet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\polynet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\resnext.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
creating build\bdist.win-amd64\egg\pretrainedmodels\models\resnext_features
copying build\lib\pretrainedmodels\models\resnext_features\resnext101_32x4d_features.py -> build\bdist.win-amd64\egg\pretrainedmodels\models\resnext_features
copying build\lib\pretrainedmodels\models\resnext_features\resnext101_64x4d_features.py -> build\bdist.win-amd64\egg\pretrainedmodels\models\resnext_features
copying build\lib\pretrainedmodels\models\resnext_features\__init__.py -> build\bdist.win-amd64\egg\pretrainedmodels\models\resnext_features
copying build\lib\pretrainedmodels\models\senet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\torchvision_models.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\utils.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\vggm.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\wideresnet.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\xception.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\models\__init__.py -> build\bdist.win-amd64\egg\pretrainedmodels\models
copying build\lib\pretrainedmodels\utils.py -> build\bdist.win-amd64\egg\pretrainedmodels
copying build\lib\pretrainedmodels\version.py -> build\bdist.win-amd64\egg\pretrainedmodels
copying build\lib\pretrainedmodels\__init__.py -> build\bdist.win-amd64\egg\pretrainedmodels
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\datasets\utils.py to utils.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\datasets\voc.py to voc.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\datasets\__init__.py to __init__.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\bninception.py to bninception.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\cafferesnet.py to cafferesnet.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\dpn.py to dpn.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\fbresnet.py to fbresnet.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\inceptionresnetv2.py to inceptionresnetv2.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\inceptionv4.py to inceptionv4.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\nasnet.py to nasnet.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\nasnet_mobile.py to nasnet_mobile.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\pnasnet.py to pnasnet.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\polynet.py to polynet.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\resnext.py to resnext.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\pretrainedmodels\models\resnext_features\resnext101_32x4d_features.py to resnext101_32x4d_features.cpython-37.pyc
error: [Errno 2] No such file or directory: 'build\\bdist.win-amd64\\egg\\pretrainedmodels\\models\\resnext_features\\__pycache__\\resnext101_32x4d_features.cpython-37.pyc.1702181039952'

One option is to use a docker image, one I frequently use is the datascience-notebook image from jupyter.一种选择是使用 docker 图像,我经常使用的是来自datascience-notebook图像。

For this:为了这:

    1. Install docker desktop for Windows, refer to this link .为 Windows 安装 docker 桌面,参考此链接
    1. Enable file sharing inside Docker Destop Settings在 Docker Destop Settings 中启用文件共享在此处输入图像描述

As you can see from the C:users\amtre I can mount any subdirectory to the container, for example, all that is within the Documents folder.正如您从C:users\amtre中看到的那样,我可以将任何子目录挂载到容器中,例如Documents文件夹中的所有子目录。

    1. Once docker has access to mount directories to a container we will be using the jupyter datascience-notebook as it already comes with some packages as default.一旦 docker 可以访问容器的挂载目录,我们将使用 jupyter datascience-notebook ,因为它已经默认附带了一些软件包。 Type on your terminal在终端上输入
docker run -it -e GRANT_SUDO=yes --user root --rm -p 8888:8888 -p 4040:4040 -v C:/users/amtre/Documents:/home/jovyan/work jupyter/datascience-notebook

it will take a while pulling the docker image, but at the end you will get the URL to access the notebook as the image above shows.拉动 docker 映像需要一段时间,但最后您将获得 URL 来访问笔记本,如上图所示。 在此处输入图像描述

  1. Inside Jupyter, open a terminal and type在 Jupyter 中,打开一个终端并输入
git clone https://github.com/Cadene/pretrained-models.pytorch.git
cd pretrained-models.pytorch
python setup.py install

this will also install 'torch', 'torchvision', 'munch', 'tqdm' as it comes in install_requires on the setup.py .这也将安装'torch', 'torchvision', 'munch', 'tqdm' ,因为它在setup.pyinstall_requires中。 When the installation is done, you should be able to start using pretrained models安装完成后,您应该可以开始使用预训练模型了

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM