如何在ubuntu20.04中安装cuDNNv8.0.5
时间: 2024-12-28 19:36:12 浏览: 7
要在Ubuntu 20.04系统上安装CUDA 11.1 (通常包含了cuDNN v8.0.5)并配置TensorFlow支持,你可以按照以下步骤操作:
1. **更新包列表**:
```bash
sudo apt update && sudo apt upgrade
```
2. **安装依赖库**:
```bash
sudo apt install -y build-essential checkinstall libncurses5-dev libncursesw5-dev libcurl4-openssl-dev libssl-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev tk-dev libx11-dev libelf-dev libbz2-dev liblzma-dev liblz4-tool liblz4-dev libzstd-dev libopenblas-dev liblapack-dev libatlas-base-dev gfortran
```
3. **下载CUDA**:
首先访问CUDA官网 (https://developer.nvidia.com/cuda-downloads),选择适合Ubuntu 20.04的版本(例如CUDA 11.1),然后下载DEB包。
4. **安装CUDA**:
下载完成后,解压并安装CUDA,例如对于`.deb`文件:
```bash
sudo dpkg -i cuda-repo-ubuntu2004_11.1.0-455.21.04_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/repos/ubuntu/repos/lists/xenial/xenial.txt
sudo apt update
sudo apt-get install cuda
```
5. **安装cuDNN**:
CUDA安装会自动处理cuDNN的安装,如果你需要手动安装,首先从NVIDIA Developer网站(https://developer.nvidia.com/cudnn)下载cuDNN压缩包,解压后运行类似下面的命令:
```bash
sudo cp -r /path/to/cudnn/include /usr/local/cuda/include/
```
6. **配置环境变量**:
将CUDA路径添加到`LD_LIBRARY_PATH`和`PYTHONPATH`:
```bash
echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export PYTHONPATH=/usr/local/cuda/include/python3.7:/usr/local/cuda:$PYTHONPATH
source ~/.bashrc
```
7. **验证安装**:
运行一些CUDA示例程序或检查CUDA、cuDNN是否可用:
```bash
nvidia-smi
python3 -c "import tensorflow as tf; print(tf.test.is_gpu_available())"
```
阅读全文