如何在Windows上将pytorch指定为软件包要求? [英] How to specify pytorch as a package requirement on windows?

查看:109
本文介绍了如何在Windows上将pytorch指定为软件包要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖pytorch的python软件包,我希望Windows用户能够通过pip进行安装(特定的软件包为: https://github.com/mindsdb/lightwood ,但我认为这与我的问题无关.

I have a python package which depends on pytorch and which I’d like windows users to be able to install via pip (the specific package is: https://github.com/mindsdb/lightwood, but I don’t think this is very relevant to my question).

执行此操作的最佳做​​法是什么?

What are the best practices for going about this ?

有一些我可以用作示例的项目吗?

Are there some project I could use as examples ?

似乎是pypi托管的Torch& torchvision与Windows不兼容,入门"部分建议从自定义pytorch存储库进行安装,但是除此之外,我不确定将其作为安装脚本的一部分的理想解决方案.

It seems like the pypi hosted version of torch & torchvision aren’t windows compatible and the "getting started" section suggests installing from the custom pytorch repository, but beyond that I’m not sure what the ideal solution would be to incorporate this as part of a setup script.

推荐答案

执行此操作的最佳做​​法是什么?

What are the best practices for going about this ?

如果您的项目依赖于未通过 PyPI 分发的其他项目,那么您必须以一种或另一种方式告知项目用户.我建议使用以下组合:

If your project depends on other projects that are not distributed through PyPI then you have to inform the users of your project one way or another. I recommend the following combination:

  • (在项目的文档页面中,或在项目的详细描述中,或在 README 中,或类似的东西)明确指定哪些依赖项无法通过PyPI获得(以及使用相应链接的可能原因)以及从中获取链接的可能位置;
  • 为方便用户使用,请在项目旁边发布预先准备好的 requirements.txt 文件以及相应的--find-links选项.
  • clearly specify (in your project's documentation pages, or in the project's long description, or in the README, or anything like this) which dependencies are not available through PyPI (and possibly the reason why, with the appropriate links) as well as the possible locations to get them from;
  • to facilitate the user experience, publish alongside your project a pre-prepared requirements.txt file with the appropriate --find-links options.

之所以(或主要原因,还有其他原因)是使用 pip 的任何人都假定(默认情况下)所有内容都将从 PyPI 下载,而没有其他地方.换句话说,任何使用 pip 的人都会信任 pypi.org 作为Python项目发行版的来源.如果 pip 突然从其他来源下载工件,则会破坏这种信任.用户应决定从其他来源下载.

The reason why (or main reason, there are others), is that anyone using pip assumes that (by default) everything will be downloaded from PyPI and nowhere else. In other words anyone using pip puts some trust into pypi.org as a source for Python project distributions. If pip were suddenly to download artifacts from other sources, it would breach this trust. It should be the user's decision to download from other sources.

因此,您可以在项目的文档中提供requirements.txt文件的示例,如下所示:

So you could provide in your project's documentation an example of requirements.txt file like the following:

# ...
torch===1.4.0  --find-links https://download.pytorch.org/whl/torch_stable.html
torchvision===0.5.0  --find-links https://download.pytorch.org/whl/torch_stable.html
# ...


更新

最好的解决方案是帮助相关项目的维护者直接在 PyPI 上发布 Windows wheels :

The best solution would be to help the maintainers of the projects in question to publish Windows wheels on PyPI directly:

  • https://github.com/pytorch/pytorch/issues/24310
  • https://github.com/pytorch/vision/issues/1774
  • https://pypi.org/help/#file-size-limit

这篇关于如何在Windows上将pytorch指定为软件包要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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