# TF、Pytorch、Python、CUDA、cuDNN版本要相容 本機檢查Nvidia Driver版本: NVIDIA-SMI * Tensorflow (tf2.6+py3.9+cuda11.2+cudnn8.1) https://www.tensorflow.org/install/source?hl=zh-tw ``` # in virtual machine conda install conda-forge::cudatoolkit=11.2.2 conda install conda-forge::cudnn=8.1.0.77 pip install tensorflow-gpu==2.6.0 pip install protobuf==3.20.* # 安裝舊版本protobuf ``` ``` import tensorflow as tf from tensorflow.python.client import device_lib print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) print("Device:", device_lib.list_local_devices()) ``` * Pytorch (torch2.4+py3.12+cuda12.4+cudnn8.9.7) https://pytorch.org/get-started/locally/ ``` # in virtual machine conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia conda install conda-forge::cudnn=8.9.7 ``` ``` # test python import torch print(torch.cuda.is_available()) print(torch.cuda.get_device_name(0)) ``` * CUDA CUDnn https://developer.nvidia.com/rdp/cudnn-archive # Reference * Ubuntu Server 24.04|22.04 安裝 Anaconda https://medium.com/@averyaveavi/ubuntu-server-22-04-%E5%AE%89%E8%A3%9D-anaconda-a8acfb9ef94c * CUDA cuDNN TensorFlow-GPU 安裝教學(Windows適用) https://medium.com/@yesaouo/cuda-cudnn-tensorflow-gpu-%E5%AE%89%E8%A3%9D%E6%95%99%E5%AD%B8-windows%E9%81%A9%E7%94%A8-%E5%A4%9A%E7%89%88%E6%9C%AC%E5%85%BC%E5%AE%B9-b2688614c506 * [Pytorch]想用GPU跑ML環境卻裝不好?看完這篇帶你避開各種雷! https://medium.com/@anannannan0102/pytorch-%E6%83%B3%E7%94%A8gpu%E8%B7%91ml%E7%92%B0%E5%A2%83%E5%8D%BB%E8%A3%9D%E4%B8%8D%E5%A5%BD-%E7%9C%8B%E5%AE%8C%E9%80%99%E7%AF%87%E5%B8%B6%E4%BD%A0%E9%81%BF%E9%96%8B%E5%90%84%E7%A8%AE%E9%9B%B7-3bf259fc7396 * 简单快速安装pytorch-gpu和tensorflow-gpu https://blog.csdn.net/qq_50698651/article/details/124051961 * GPU版PyTorch安装、GPU版TensorFlow安装(详细教程) https://blog.csdn.net/qq_62928482/article/details/139708830 * Install CUDA, cuDNN in conda virtual environment and setup GPU support using Tensorflow https://medium.com/@Rahul_Meduri/install-cuda-cudnn-in-conda-virtual-environment-and-setup-gpu-support-using-tensorflow-f8a4c942b6ea