行业知识
linux上pip3 install torch==1.11和pip3 install torch==1.11+cu115区别
2026-11-08 10:46:26
来源:互联网转载
在linux上安装torch���, 如果环境安装好了CUDA环境, 那么安装torch时不用刻意指定带cuda的版本, 最终安装的也是支持GPU的torch版本。但是仍然有一些小的区别,主要就是支持CUDA版本的不同。
()(leo_py37) pinefield@edge-gpu-01:/data/codes/OpenPCDet$ pip3 install torch==1.11Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting torch==1.11 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/94/32/96a0955e5d6ed8a837eda5ca095dd2694c4617cfa70ca599660cd5ff7447/torch-1.11.0-cp37-cp37m-manylinux1_x86_64.whl (750.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 750.6/750.6 MB 840.4 kB/s eta 0:00:00Collecting typing-extensions Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl (33 kB)Installing collected packages: typing-extensions, torchSuccessfully installed torch-1.11.0 typing-extensions-4.7.1(leo_py37) pinefield@edge-gpu-01:/data/codes/OpenPCDet$ python3 Python 3.7.5 (default, Oct 25 2019, 15:51:11) [GCC 7.3.0] :: Anaconda, Inc. on linuxType "help", "copyright", "credits" or "license" for more information.>>> import torch /home/pinefield/anaconda3/envs/leo_py37/lib/python3.7/site-packages/torch/_masked/__init__.py:223: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:68.) example_input = torch.tensor([[-3, -2, -1], [0, 1, 2]])>>> torch.__version__'1.11.0+cu102'>>> (leo_py37) pinefield@edge-gpu-01:/data/joyiot/liyong/codes/OpenPCDet$ pip3 list |grep torch torch 1.11.0
如上图, 安装torch时未指定需要安装gpu版本, 但是实际安装的也是支持gpu的版本。只是安装了支持cuda 10.2的版本。 实际上系统的cuda版本是11.5.
如果明确指定cuda版本, 则安装的就是对应的版本。
()(leo_py37) pinefield@edge-gpu-01:/data/codes/OpenPCDet$ pip3 install torch==1.11.0+cu115Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleERROR: Could not find a version that satisfies the requirement torch==1.11.0+cu115 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1)ERROR: No matching distribution found for torch==1.11.0+cu115(leo_py37) pinefield@edge-gpu-01:/data/joyiot/liyong/codes/OpenPCDet$ pip3 install torch==1.11.0+cu115 --extra-index-url https://download.pytorch.org/whl/cu115Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://download.pytorch.org/whl/cu115Collecting torch==1.11.0+cu115 Using cached https://download.pytorch.org/whl/cu115/torch-1.11.0%2Bcu115-cp37-cp37m-linux_x86_64.whl (2138.4 MB)Requirement already satisfied: typing-extensions in /home/pinefield/anaconda3/envs/leo_py37/lib/python3.7/site-packages (from torch==1.11.0+cu115) (4.7.1)Installing collected packages: torch Attempting uninstall: torch Found existing installation: torch 1.11.0 Uninstalling torch-1.11.0: Successfully uninstalled torch-1.11.0Successfully installed torch-1.11.0+cu115(leo_py37) pinefield@edge-gpu-01:/data/codes/OpenPCDet$ python3 Python 3.7.5 (default, Oct 25 2019, 15:51:11) [GCC 7.3.0] :: Anaconda, Inc. on linuxType "help", "copyright", "credits" or "license" for more information.>>> import torch /home/pinefield/anaconda3/envs/leo_py37/lib/python3.7/site-packages/torch/_masked/__init__.py:223: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:68.) example_input = torch.tensor([[-3, -2, -1], [0, 1, 2]])>>> torch.__version__'1.11.0+cu115'>>> (leo_py37) pinefield@edge-gpu-01:/data/codes/OpenPCDet$ pip3 list |grep torch torch 1.11.0+cu115
注意, 直接安装可能会找不到对应版本, 需要通过 --extra-index-url https://download.pytorch.org/whl/cu115指定torch官方的下载地址。
下一篇:宝塔面板怎么修改模板?