pytorch无法使用cuda和cudnn返回false

下面乱七八糟的实验过后问题解决,用了三天的时间,总算搭建成功了

 


查了无数资料无法解决问题,将目标定为pytorch和cuda版本不匹配,重新下载pytorch发现报错

在pytorch官方可以下载版本对应的pytorch

从本地开始 |Py火炬 (pytorch.org)

这里根据自己需要点一点,然后复制下面代码粘贴到这里

懂得都懂,我不知道用管理员权限用不用有没有区别,保险起见还是用了

报的错误说什么网页404

出于好奇,点开看看

额,我寻思不太对劲,可能是镜像源出了问题,所以就换一下镜像源(pass:换之前把之前的恢复到默认)

恢复默认的代码:

conda config --remove-key channels

查看当前源的代码:

conda config --show channels

然后下面是我找到的几个网站的镜像:

清华的:我的命令行好像不支持一下全粘贴,所以我就放成一个个的和在一起的,看个人需要了

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 --set show_channel_urls yes
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 --set show_channel_urls yes

中科大的:

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/pytorch/

不耽误时间了http://t.csdnimg.cn/Odvni你们去看他的吧

不过换了好像还不行,有教程说把https换成http就行,我再去试试

三天没配成环境,电脑都重装了,气笑了


更新:

之前的网页换了也没成功,好消息是又找到了解决办法

只适用于无法下载pytorch:

在c盘用户打开.condarc,选择记事本打开

把下面这个复制粘贴过去,保存,再下载pytorch

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

 打开

输入

conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia

 可以看到已经开始龟速下载了,改了源都这么满我真是澡称冯福。。。睡觉去,自己下载吧

### 安装支持CUDAPyTorch于Linux系统 对于希望在Linux环境下配置带有CUDA支持的PyTorch环境而言,操作流程涉及几个重要环节。首先确认已安装NVIDIA驱动程序以及对应的CUDA Toolkit版本兼容性[^3]。 #### 验证现有CUDA设置 为了确保后续步骤顺利执行,在开始之前应当验证当前系统的CUDA状态: ```bash nvcc --version nvidia-smi ``` 上述命令用于展示编译器版本显卡运行情况,从而判断是否具备必要的硬件条件支持软件。 #### 创建虚拟环境(可选) 推荐创建独立Python虚拟环境来管理依赖关系,防止不同项目间发生冲突。可以利用`venv`模块完成此任务: ```bash python3 -m venv my_pytorch_env source my_pytorch_env/bin/activate ``` 激活后的环境中将隔离其他全局包的影响,有助于保持项目的整洁性稳定性。 #### 安装PyTorch及相关组件 通过官方渠道提供的工具简化安装过程,特别是当目标平台为Linux且需启用特定功能如CUDA加速时。访问[官方网站](https://pytorch.org/get-started/locally/)并按照提示选择适合的操作系统、包管理CUDA版本组合后复制给出的指令集。通常情况下,这将是类似于下面的形式: ```bash pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117 ``` 这里假设选择了适用于CUDA 11.7版本的二进制文件;实际使用前应根据个人需求调整URL中的参数以匹配本地环境的具体状况。 #### 测试安装成果 最后一步是对新安装的内容进行基本的功能测试,确保一切正常工作。可以通过简单的代码片段来进行初步检验: ```python import torch print(torch.__version__) if torch.cuda.is_available(): print(f"CUDA is available, using {torch.cuda.get_device_name(0)}") else: print("No CUDA detected.") ``` 这段脚本不仅展示了PyTorch本身的版本号,还会告知是否存在可用的GPU设备及其名称,以此证明CUDA集成的成功与否。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值