由于依赖问题无法在poetry中安装gpu版本的torch和torchvision
Cannot install the gpu version of torch and torchvision in poetry due to a dependency problem
我正在尝试使用诗歌为机器学习创建一个虚拟环境。所以,我使用 pytorch 作为深度学习的框架。我将提取我的 pyproject.toml.
的相关部分
[tool.poetry.dependencies].
python = "^3.8"
torch = { url = "https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
torchvision = { url = "https://download.pytorch.org/whl/cu111/torchvision-0.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl" }
由于pytroch使用GPU,需要通过指定whl文件进行安装。如果您这样安装,pytroch
的版本将是 1.8.0+cu111
。 torchvision
对应pytorch的1.8.0
是0.9.0
。这个torchvision
依赖的pytroch版本是1.8.0
(没有cu111
)。因此,我无法使用诗歌创建虚拟环境并出现以下错误。
SolverProblemError
Because torchvision (0.9.0) depends on torch (1.8.0)
and mdwithpriorenergy depends on torch (1.8.0+cu111), torchvision is forbidden.
So, because mdwithpriorenergy depends on torchvision (0.9.0), version solving failed.
So, because [env name] depends on torchvision (0.9.0), version solving failed.
我还在上面 pyproject.toml 中对 torchvision 进行了以下更改,但它们没有用。
[tool.poetry.dependencies].
python = "^3.8"
torch = { url = "https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
- torchvision = { url = "https://download.pytorch.org/whl/cu111/torchvision-0.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
+ torchvision = "*"
在这种情况下,我收到以下错误
AttributeError
'EmptyConstraint' object has no attribute 'allows'.
请告诉我如何解决这个错误。
据我所知,这在诗歌中尚不支持(没有丑陋的黑客),请参阅 Issue 2613。
也就是说,我正在维护一个名为 relaxed-poetry 的分支。这是一个非常年轻的叉子,但它通过以下配置支持您想要的东西:
[tool.poetry.dependencies]
python = "^3.8"
torch = { version = "=1.8.0+cu111", source = "pytorch" }
torchvision = { version = "=0.9.0+cu111", source = "pytorch" }
[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu111/"
secondary = true
如果觉得对你有帮助,可以和诗歌一起安装,用命令rp
代替
请注意,安装需要一些时间,因为这是一个很大的依赖项,而且源代码相对较慢..
我正在尝试使用诗歌为机器学习创建一个虚拟环境。所以,我使用 pytorch 作为深度学习的框架。我将提取我的 pyproject.toml.
的相关部分[tool.poetry.dependencies].
python = "^3.8"
torch = { url = "https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
torchvision = { url = "https://download.pytorch.org/whl/cu111/torchvision-0.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl" }
由于pytroch使用GPU,需要通过指定whl文件进行安装。如果您这样安装,pytroch
的版本将是 1.8.0+cu111
。 torchvision
对应pytorch的1.8.0
是0.9.0
。这个torchvision
依赖的pytroch版本是1.8.0
(没有cu111
)。因此,我无法使用诗歌创建虚拟环境并出现以下错误。
SolverProblemError
Because torchvision (0.9.0) depends on torch (1.8.0)
and mdwithpriorenergy depends on torch (1.8.0+cu111), torchvision is forbidden.
So, because mdwithpriorenergy depends on torchvision (0.9.0), version solving failed.
So, because [env name] depends on torchvision (0.9.0), version solving failed.
我还在上面 pyproject.toml 中对 torchvision 进行了以下更改,但它们没有用。
[tool.poetry.dependencies].
python = "^3.8"
torch = { url = "https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
- torchvision = { url = "https://download.pytorch.org/whl/cu111/torchvision-0.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl"}
+ torchvision = "*"
在这种情况下,我收到以下错误
AttributeError
'EmptyConstraint' object has no attribute 'allows'.
请告诉我如何解决这个错误。
据我所知,这在诗歌中尚不支持(没有丑陋的黑客),请参阅 Issue 2613。
也就是说,我正在维护一个名为 relaxed-poetry 的分支。这是一个非常年轻的叉子,但它通过以下配置支持您想要的东西:
[tool.poetry.dependencies]
python = "^3.8"
torch = { version = "=1.8.0+cu111", source = "pytorch" }
torchvision = { version = "=0.9.0+cu111", source = "pytorch" }
[[tool.poetry.source]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu111/"
secondary = true
如果觉得对你有帮助,可以和诗歌一起安装,用命令rp
代替
请注意,安装需要一些时间,因为这是一个很大的依赖项,而且源代码相对较慢..