Problem: pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url

Recently I needed to deploy the cuda11.8 related configuration files on the anaconda virtual environment in vscode.But when I input this command

pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url

It cannot download packages related to CUDA automatically from that website, including:
I’ve tried numerous devices, including servers and laptops running Ubuntu 22.04, some of which can download all configurations properly, while others cannot. I’d like to understand how to resolve this issue.This is all the code instructions I entered in the vscode console:

conda create -n <myenv> python=3.10.13
conda activate <myenv>
conda install nvidia/label/cuda-11.8.0::cuda-toolkit
pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url
conda install -c "nvidia/label/cuda-11.8.0" cuda-nvcc
conda install packaging

this problem had been solved!!! you only need to follow these steps:

  • check your pip version
pip --version

output → pip 23.3.1 from /root/miniconda3/lib/python3.12/site-packages/pip (python 3.12)

  • if your pip version is higher than 22.0.2, please downgrade the version
python -m pip install pip==20.0.2
  • enter the following command:
pip3 install torch torchvision torchaudio --index-url

Note: Before running this command, ensure that torch is not installed in the virtual environment; otherwise, CUDA-related dependencies cannot be installed
Unknown: How do I install cuda-runtime and other packages independently in anaconda without installing torch