Cannot install the gpu version of torch and torchvision in poetry due to a dependency problem

I am trying to create a virtual environment for machine learning using poetry. So, I am using pytorch as a framework for deep learning. I will extract the relevant part of my 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" }

Since pytroch uses the GPU, you need to install it by specifying the whl file. If you install it this way, the version of pytroch will be 1.8.0+cu111. torchvision corresponding to 1.8.0 of pytorch is 0.9.0. The version of pytroch that this torchvision depends on is 1.8.0 (without cu111). Therefore, I cannot create a virtual environment using poetry with the following error.


  SolverProblemError

  Because torchvision (0.8.0) depends on torch (1.7.0)
   and mdwithpriorenergy depends on torch (1.8.0+cu111), torchvision is forbidden.
  So, because mdwithpriorenergy depends on torchvision (0.8.0), version solving failed.

So, because [env name] depends on torchvision (0.8.0), version solving failed. 

I also made the following changes to torchvision in pyproject.toml above, but they did not work.

[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 = "*"

In this case, I received the following error

  AttributeError

  'EmptyConstraint' object has no attribute 'allows'.

Please tell me how to solve this error.

Are you able to solve this problem? I am facing the same issue.

Have you solve this problem ? I met the same problem now.