惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
D
DataBreaches.Net
S
Secure Thoughts
B
Blog
S
Schneier on Security
Y
Y Combinator Blog
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Full Disclosure
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Hacker News
The Hacker News
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
T
The Exploit Database - CXSecurity.com
雷峰网
雷峰网
博客园 - 司徒正美
Help Net Security
Help Net Security
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Cisco Talos Blog
Cisco Talos Blog
L
LINUX DO - 热门话题
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threat Research - Cisco Blogs
Recent Announcements
Recent Announcements
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Heimdal Security Blog
Jina AI
Jina AI
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
Microsoft Security Blog
Microsoft Security Blog
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
D
Docker
I
Intezer
C
Check Point Blog
Cloudbric
Cloudbric
小众软件
小众软件
V2EX - 技术
V2EX - 技术

Miya's Blog

博客大修记录 (2026) 我在用什么? 记一次软件源归档导致的 CI 构建问题 Denoising Diffusion Null-Space Model 可逆神经网络 Invertible Diffusion Model 常见推理后端安装及配置 Jupyter Notebook 安装及配置 论文复现 - MAGIS 浅谈非易失内存 深度学习环境配置(一) Debian 配置 V2Ray-A Diffusion 入门 CV 基础(二) CV 基础(一) 内存体系结构 - 简述 Programming Persistent Memory 第三章笔记 地址映射与TLB CuBase 小记
深度学习环境配置(二)
Miya · 2025-04-20 · via Miya's Blog

Conda 配置 CUDA/CuDNN/PyTorch

希望在服务器上重新配置一套 Python / Pytorch / CUDA / CuDNN 环境。之前的环境为了兼容一些旧项目 (点名 TVM) 而使用了各个驱动和软件包的较低版本,导致运行新项目时易产生兼容性问题。

在 Conda 中完成配置。

安装 Anaconda3

安装命令如下。

1
2
chmod 777 Anaconda3-2024.10-1-Linux-x86_64.sh 
./Anaconda3-2024.10-1-Linux-x86_64.sh

交互内容使用默认选项即可。

1
2
3
4
5
6
7







环境变量设置

在 /etc/profile 中配置 Conda 路径,如下。

1
2
3

export PATH=/root/anaconda3/bin:$PATH
$ source /etc/profile

检查 Conda 版本,有输出即为安装成功。

1
conda -V  

创建 Python 环境

以 Python 3.11 为例,创建 Conda 环境

1
conda create -n torch python=3.11

执行初始化检查,并刷新 .bashrc

1
2
conda init
source /root/.bashrc

笔者这里使用 python3 才能看到 Conda 安装的 Python 版本,这是因为此前使用 alias 进行过 Python 版本切换。

1
2
conda activate torch
python3 -V

安装 CUDA & CuDNN

采用 CudaToolkit 方式安装 CUDA。首先查看当前 Nvidia Driver 支持的最高版本,然后执行如下命令

1
(torch) conda install nvidia/label/cuda-12.2.2::cuda-toolkit

查找 CuDNN 可用版本

1
(torch) conda search cudnn

输出如下

1
2
3
4
5
Loading channels: done
# Name Version Build Channel
# cudnn 7.0.5 cuda8.0_0 pkgs/main
# cudnn 8.9.2.26 cuda11_0 pkgs/main
# cudnn 9.1.1.17 cuda12_1 pkgs/main

安装指定版本

1
(torch) conda install cudnn=9.1

安装 PyTorch

参考 PyTorch 官网提供的 Instruction 安装 PyTorch (p.s. 现在对 Rocm 支持越来越好了,AMD YES)

1
conda install pytorch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 pytorch-cuda=12.1 -c pytorch -c nvidia

首次安装时意外卡在 99%,Ctrl + C 后重新安装,出现如下报错

1
2
3
CondaVerificationError: The package for pytorch located at /root/anaconda3/pkgs/pytorch-2.5.1-py3.11_cuda12.1_cudnn9.1.0_0
appears to be corrupted. The path 'lib/python3.11/site-packages/torch/include/ATen/cuda/CUDAApplyUtils.cuh'
specified in the package manifest cannot be found.

执行如下命令清理损坏的包

1
(torch) conda clean --packages

交互内容使用默认选项即可。

1
2
3



可能在 Solving environment 一行卡住较长时间,耐心等待。

测试

编写一个小脚本测试当前 Conda 环境中安装的驱动和软件包版本。

1
2
3
4
print(torch.backends.cudnn.version())  
print(torch.__version__)
print(torch.version.cuda)
print(torch.cuda.is_available())

References

  1. Cuda Toolkit | Anaconda.org
  2. Previous PyTorch Versions | PyTorch
  3. Linux环境安装Anaconda(详细图文)_linux安装anaconda-CSDN博客
  4. conda环境中配置cuda+cudnn+pytorch深度学习环境_conda虚拟环境安装cuda-CSDN博客

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Miya's Blog