You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境下安装PyTorch后无法导入的问题求助

Troubleshooting PyTorch Import Failure on Windows (CPU-only Setup)

Hey there! Let's break down why your PyTorch import isn't working and fix it step by step.

What Went Wrong

You installed a CUDA-enabled version of PyTorch 0.3.1 from the peterjc123 channel, but since you don't have an NVIDIA GPU, this package tries to load CUDA libraries that aren't present on your system. On top of that, third-party channels like peterjc123 don't always offer the same reliability as official PyTorch packages, especially for older versions.

Step 1: Uninstall the Problematic Package

First, let's remove the broken PyTorch installation completely. Open your conda terminal and run:

conda uninstall pytorch

Follow the on-screen prompts to confirm the uninstallation.

Step 2: Install the Official CPU-only PyTorch

Since you're using Python 3.6 and don't have a GPU, we'll install an official CPU-compatible version that works with your setup. Python 3.6 supports PyTorch versions up to 1.5.x, so we'll use that for compatibility.

Option A: Using Conda

This is the most reliable method for conda environments:

conda install pytorch-cpu torchvision-cpu -c pytorch

This pulls official CPU-only packages directly from PyTorch's conda channel.

Option B: Using Pip

If conda runs into compatibility issues, try pip instead:

pip install torch==1.5.0+cpu torchvision==0.6.0+cpu

If pip can't locate the package, you can download the appropriate wheel file for Python 3.6 from PyTorch's official archive and install it locally with pip install <path-to-your-downloaded-wheel-file>.

Step 3: Verify the Installation

Open a Python shell (or your IDE's terminal) and test the import:

import torch
print(torch.__version__)
print(torch.cuda.is_available())  # This should return False, which is normal for a CPU-only setup

If you don't get any error messages, your PyTorch installation is working correctly!

内容的提问来源于stack exchange,提问作者Eypros

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:35:44