pytorch安装问题总结

PyTorch的安装教程_酒归.的博客-CSDN博客_怎么安装pytorch  

按照这个,中间出现过问题,

尝试过:

conda create -n pytorch_1.11_cpu python==3.9
C:\Users\Administrator\.condarc
conda activate pytorch_1.11_cpu
(pytorch_1.11_cpu) C:\Users\Administrator>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Warning: 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/' already in 'channels' list, moving to the top

(pytorch_1.11_cpu) C:\Users\Administrator>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

(pytorch_1.11_cpu) C:\Users\Administrator>conda config --set show_channel_urls yes

(pytorch_1.11_cpu) C:\Users\Administrator>conda install pytorch torchvision torchaudio cpuonly -c pytorch

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true


pytorch和torchvision下载失败,主要是anaconda延迟过高导致

增加国内镜像源来安装

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
 

最后保险起见,多加了几个源

conda install pytorch torchvision torchaudio cpuonly -c pytorch中把 -c pytorch去掉,直接从清华镜像中下载变成conda install pytorch torchvision torchaudio cpuonly

就可以了

(pytorch_1.11_cpu) C:\Users\Administrator>python
Python 3.6.15 (default, Dec  3 2021, 18:25:24) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available
<function is_available at 0x000001BB06602488>
>>> torch.cuda.is_available()
False

False说明只能用CPU,安装的就是CPU版本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: PyTorch 可以通过安装软件包来安装。可以在命令行中使用 pip 进行安装,命令如下: ``` pip install torch torchvision ``` 如果您还需要安装 CUDA 版本的 PyTorch,可以在上述命令的基础上,添加以下内容: ``` pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu22/torch_stable.html ``` 请注意,您需要在安装 CUDA 版本的 PyTorch 之前,先安装 CUDA 和 cuDNN。 ### 回答2: PyTorch是一个流行的深度学习框架,通过使用GPU加速计算,可以在图形处理器上更快地训练和优化深度神经网络模型。下面是关于如何安装PyTorch的步骤。 1. 首先,确保你的计算机上已经安装Python。你可以通过命令行运行`python --version`来检查Python版本。如果没有安装,可以从官方网站www.python.org下载并安装。 2. 接下来,我们需要安装PyTorch的依赖项。其中包括NumPy、Matplotlib等。你可以使用以下命令来安装依赖项: ```shell pip install numpy matplotlib ``` 3. 然后,我们需要选择合适的PyTorch版本。根据你的操作系统和CUDA版本,可以在官方网站(https://pytorch.org)上找到合适的PyTorch版本。 4. 在安装PyTorch之前,需要先安装对应的CUDA和cuDNN(如果你有NVIDIA GPU的话)。这样可以充分利用GPU加速PyTorch的计算。可以参考官方网站上提供的安装指南进行操作。 5. 一旦你确定了正确的PyTorch版本并且安装了所需的依赖项和GPU驱动,你可以使用以下命令安装pytorch: ```shell pip install torch torchvision ``` 这将会下载和安装PyTorch以及相关的包。 6. 安装完成后,可以在Python环境中导入torch模块,并开始使用PyTorch进行深度学习实验了。 总结:要安装PyTorch,首先确保Python已经安装,然后安装相应的依赖项。接下来,选择合适的PyTorch版本并安装相关的CUDA和cuDNN(如果需要)。最后,使用pip命令安装PyTorchtorchvision。现在你就可以开始使用PyTorch进行深度学习的开发了。 ### 回答3: 安装PyTorch可以通过多种方式进行,以下是其中一种常见的安装方法: 1. 首先,确认你的计算机已经安装Python,并且版本为3.6或以上。如果没有安装Python,你可以从官方网站下载并安装最新的Python版本。 2. 打开终端或命令提示符,运行以下命令安装PyTorch的最新版本: ``` pip install torch torchvision ``` 这个命令将自动安装PyTorch及其相关库。 3. 在安装过程中,你可能需要等一段时间,因为PyTorch安装包可能相对较大。 4. 安装完成后,可以通过运行以下代码来验证安装是否成功: ```python import torch if torch.cuda.is_available(): print("Congratulations! PyTorch has been successfully installed. You can use GPU acceleration.") else: print("Congratulations! PyTorch has been successfully installed. You can use CPU for computation.") ``` 如果成功打印出"Congratulations! PyTorch has been successfully installed",则表示安装成功。 记得最好在虚拟环境中安装PyTorch,以确保不干扰其他项目和库的设置。 总之,通过以上步骤,你就可以成功安装PyTorch并开始使用它进行深度学习的任务了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值