conda换源+查看cuda版本+anaconda一步安装torch和cuda

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/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch

conda config --set show_channel_urls yes

直接改.condarc: 

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - defaults
show_channel_urls: true
ssl_verify: true

清华源不行就科大吧,最近挺好使的(2021.3.3)

channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
auto_activate_base: false


查看自己cuda版本:

win键,找到#号,选择N,找到Nvida control panel,右上,帮助,系统信息,组件,

在anaconda里装经常会弹框 multiple error

还是去pytorch官网找命令吧,去掉-c 就行


经验所得,以上都是奇技淫巧,离线安装永远的神

https://download.pytorch.org/whl/torch_stable.html

可以去pytorch官网找到自己要的对应的版本,再自己下载好离线安装。


<think>嗯,用户想知道如何在Anaconda查看安装CUDA版本。我之前在引用里看到,Anaconda虚拟环境中安装CUDA其实是cudatoolkit包,而不是系统级的CUDA。所以用户可能误以为需要像在系统里那样用nvidia-smi或者nvcc命令,但实际上在conda环境里不行。 首先,我需要确认用户是否了解Anaconda环境中的CUDA是独立于系统的。根据引用[2][4],安装的是cudatoolkitcudnn,所以不能用常规命令查看版本。用户可能需要通过PyTorch或者TensorFlow这样的框架来获取版本信息。 然后,我应该分步骤指导用户。首先进入对应的conda环境,然后启动Python解释器,导入torch库,使用torch.version.cuda查看版本。另外,查看cudnn版本的方法也类似,用torch.backends.cudnn.version()。这些步骤在引用[2][4]中提到过,需要正确引用。 另外,用户可能还关心如何确认CUDA是否可用,所以应该建议他们运行torch.cuda.is_available()torch.cuda.device_count(),这些在引用[4]里有说明。同时,提醒用户如果在环境中没有正确安装PyTorch的GPU版本,可能无法获取正确信息,可能需要重新安装。 还要注意用户可能的误区,比如直接在系统中CUDA版本,这时候需要解释Anaconda环境中的CUDA是独立的,不会影响系统版本,如引用[2]所述。可能需要对比两种查看方式,避免混淆。 最后,生成相关问题的时候,要考虑用户接下来可能遇到的问题,比如安装步骤、换源加速、验证安装有效性等,这些在引用[1]、[3]、[4]里都有涉及,可以引导用户进一步学习。</think>在Anaconda查看安装CUDA版本,需通过Python环境调用PyTorch库实现。以下是具体步骤: ### 步骤详解 1. **激活目标虚拟环境** ```bash conda activate 环境名称 ``` 若未创建环境,需先通过`conda create -n 环境名称 python=版本号`创建 2. **进入Python交互模式** ```bash python ``` 3. **执行询命令** ```python import torch # 查看CUDA是否可用 print(torch.cuda.is_available()) # 输出True表示GPU可用[^4] # 查看CUDA版本 print(torch.version.cuda) # 例如输出11.0[^2] # 查看cudnn版本 print(torch.backends.cudnn.version()) ``` ### 注意事项 - 该方法仅适用于通过`conda install cudatoolkit`安装CUDA工具包[^1] - 系统中独立安装CUDA版本需使用`nvcc --version`查看,与Anaconda环境内的版本可能不同 - 若输出`False`,需检是否安装了GPU版PyTorch(如`pytorch-cuda=11.0`) ### 验证安装有效性 ```python import torch # 输出可用GPU数量 print(torch.cuda.device_count()) # 正常应≥1 # 输出当前GPU型号 print(torch.cuda.get_device_name(0)) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值