使用pip3安装PyTorch和PyG

使用python3pip3命令安装python依赖库。

shell 复制代码
# python3 -V
Python 3.12.3
# 
# pip3 -V 
pip 25.0.1 from /root/.pyenv/versions/3.12.3/lib/python3.12/site-packages/pip (python 3.12)
ini 复制代码
Usage:   
  pip3 install [options] <package> ...
  pip3 install [options] -r <requirements file> ... 
  
  pip3 uninstall [options] <package> ...
  pip3 uninstall [options] -r <requirements file> ... 

GPU驱动和Cuda工具

GPU规格:NVIDIA TU104GL [Tesla T4] 驱动和Cuda版本:NVIDIA-SMI 550.127.08 Driver Version: 550.127.08 CUDA Version: 12.4

shell 复制代码
# lspci | grep -i nvidia
00:07.0 3D controller: NVIDIA Corporation TU104GL [Tesla T4] (rev a1)
# 
# nvidia-smi
Thu Apr 10 12:13:49 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.127.08             Driver Version: 550.127.08     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Tesla T4                       On  |   00000000:00:07.0 Off |                    0 |
| N/A   29C    P8              9W /   70W |       1MiB /  15360MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
# 
# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0
# 
# nvidia-smi --query-gpu=name,memory.total,utilization.gpu,temperature.gpu --format=csv
name, memory.total [MiB], utilization.gpu [%], temperature.gpu
Tesla T4, 15360 MiB, 0 %, 29

PyTorch安装

PyTorch , Tensors and Dynamic neural networks in Python with strong GPU acceleration

shell 复制代码
pip3 install torch torchvision 
torch-2.6.0

pip3 install -r pytorch/requirements.txt 
pip3 install scikit-learn tqdm gpytorch skorch 

PyG安装

PyG is the ultimate library for Graph Neural Networks Build graph learning pipelines with ease

shell 复制代码
pip3 install torch_geometric 
torch_geometric-2.6.1

# python3 -c "import torch; print(torch.__version__)" 
2.6.0+cu124
# python3 -c "import torch; print(torch.version.cuda)" 
12.4
# python3 -c "import torch; print(torch.cuda.device_count())" 
1

pip3 install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.6.0+cu124.html 

Python示例代码依赖

shell 复制代码
pip3 install -r pyg-examples/requirements.txt 

如何导出Python项目的库依赖文件requirements.txt,自行搜索DeepSeek、ChatGPT或Google/谷歌。

相关推荐
郝学胜-神的一滴12 分钟前
深度学习框架新纪元:PyTorch核心原理与工程实践全解析
人工智能·pytorch·python·深度学习·机器学习
gujunge10 小时前
Spring with AI (2): 评估答案——UnitTest引入
ai·大模型·llm·openai·qwen·rag·spring ai·deepseek
树獭叔叔15 小时前
大模型中的KL散度:从理论到实践的完整指南
后端·aigc·openai
如若12316 小时前
WSL2安装Ubuntu完整教程:自定义安装目录到D盘(--location一键搞定)
linux·运维·服务器·pytorch·python·ubuntu·计算机视觉
沸点小助手16 小时前
「OpenClaw今天想篡位了吗」沸点获奖名单公示|本周互动话题上新🎊
aigc·openai·ai编程
愣锤17 小时前
深入分析OpenClaw爆火出圈的根本原因
人工智能·openai·agent
做cv的小昊19 小时前
【Video Agent】(Arxiv2601,Meta)Agentic Very Long Video Understanding
论文阅读·计算机视觉·语言模型·音视频·openai·论文笔记·视频理解
郝学胜-神的一滴20 小时前
人工智能发展漫谈:从专家系统到AIGC,再探深度学习核心与Pytorch入门
人工智能·pytorch·python·深度学习·算法·cnn·aigc
Dxy123931021620 小时前
PyTorch的CyclicLR详细介绍:给模型训练装上“涡轮增压”
人工智能·pytorch·python
Keep_Trying_Go1 天前
基于GAN的文生图算法详解(Text to Image Generation with Semantic-Spatial Aware GAN)
人工智能·pytorch·神经网络·生成对抗网络·计算机视觉