ubuntu20.04 4090环境配置(全网)
时间: 2024-12-24 20:14:48 浏览: 12
Ubuntu 20.04版本搭配NVIDIA GeForce RTX 4090显卡的配置通常涉及到驱动程序、CUDA和深度学习框架如TensorFlow或PyTorch的安装。以下是基本步骤:
1. **更新系统**:
```
sudo apt update && sudo apt upgrade
```
2. **添加NVIDIA官方软件源**:
- 首先,需要移除内建的开源驱动(`nvidia-driver`),因为RTX 4090支持的是非开源的CUDA驱动:
```
sudo apt autoremove nvidia*
```
- 添加NVIDIA Studio的驱动源,如果你是专业用户:
```
curl https://developer.nvidia.com/discover/sites/gpuportal/files/NVIDIA-Linux-x86_64-470.57.run | bash
```
- 如果是普通用户,添加CUDA certified的驱动源:
```
echo "deb http://us.download.nvidia.com卡车/tesla/470/x86_64 ./" | sudo tee /etc/apt/sources.list.d/nvidia-470.list
wget -q -O- https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub | sudo apt-key add -
```
3. **安装驱动**:
```
sudo apt-get install nvidia-driver-470
```
4. **验证驱动安装**:
```
nvidia-smi
```
5. **安装CUDA**:
- 下载并安装CUDA Toolkit for Ubuntu 20.04(https://developer.nvidia.com/cuda-downloads),选择适合RTX 4090的版本。
- 完成安装后,在终端输入`nvcc --version`确认安装成功。
6. **设置环境变量**:
- 编辑`~/.bashrc`文件添加以下行以让环境变量生效:
```
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export CPATH=$CPATH:$CUDA_HOME/include
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64
```
7. **安装GPU加速库**:
- 对于深度学习框架,例如TensorFlow,可以使用以下命令安装GPU版本:
```bash
pip install tensorflow-gpu
```
- 或者安装PyTorch:
```bash
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/torch_stable.html
```
8. **启动图形界面** (如果需要):
```
sudo service lightdm start
```
阅读全文