机器学习环境搭建

系统

系统方面,目前经基本测试,最好选择ubuntu 22 LTS。
图省事的话,可以直接选择desktop 22 LTS版本,英伟达驱动基本自动能装好,
硬件设备:intel 14、3090 24GB

测试驱动是否安装成功

1
nvidia-smi

应该显示类似输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.107.02 Driver Version: 550.107.02 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 NVIDIA GeForce RTX 3090 Off | 00000000:01:00.0 Off | N/A |
| 0% 44C P8 26W / 350W | 109MiB / 24576MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 1304 G /usr/lib/xorg/Xorg 86MiB |
+-----------------------------------------------------------------------------------------+

驱动

1.参考英伟达官方教程
2.参考英伟达CUDA Toolkit
3.参考英伟达cuDNN

安装cuda驱动

1
2
3
4
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-6

安装cuDDN驱动

1
2
3
4
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cudnn

docker

1
2
sudo apt install -y nvidia-docker2
sudo systemctl restart docker

torch

1
pip3 install torch torchvision torchaudio

tensorflow

1
pip3 install tensorflow