Cài đặt tensorflow trên ubuntu 22.04
1. install anaconda and nvidia driver OK.
– Kiểm tra bằng cú pháp : nvidia-smi
Các bạn vào link để xem phiên bản phù hợp nhất với Tensorflow: https://www.tensorflow.org/install/source#gpu.
2. Start:
conda create –name=tf python=3.9
conda activate tf
conda install -c conda-forge cudatoolkit=11.8 cudnn=8.9.2.26
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo ‘export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/’ > $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
– Close terminal and open terminal
conda activate tf
python3 -m pip install tensorflow==2.10
# Verify install:
python3 -c “import os; os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘3’; import tensorflow as tf; print(‘Num GPUs Available: ‘, len(tf.config.list_physical_devices(‘GPU’)))”
OK IF :
Number of GPU(s): 1
—- test —–
git clone https://github.com/Cuongyd196/tensorflow-gpu-test
cd tensorflow-gpu-test
python run.py