Windows
Windows tensorflow 支持GPU的版本最高是2.10
powershell 或者 Anaconda Prompt 输入以下命令安装,每次输入一个命令,执行完成再输入,等待最后安装完成记得要验证
Tensorflow 2.2
conda create -n tf2.2_py3.8 python=3.8
conda activate tf2.2_py3.8
pip install tensorflow-gpu==2.2.0
conda install -c conda-forge cudatoolkit=10.1 cudnn=7.6
pip install protobuf==3.20.0
pip install numpy==1.19.5
Tensorflow 2.5
conda create -n tf2.5_py3.7 python=3.7
conda activate tf2.5_py3.7
conda install tensorflow-gpu=2.5
Tensorflow 2.9
conda create -n tf2.9_py3.8 python=3.8
conda activate tf2.9_py3.8
pip install tensorflow-gpu==2.9.0
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1
Tensorflow 2.10
conda create -n tf2.10_py3.8 python=3.8
conda activate tf2.10_py3.8
pip install tensorflow-gpu==2.10.0
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1
验证安装环境
python -c "from tensorflow.python.client import device_lib; print(device_lib.list_local_devices())"
问题1
Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
ubuntu 需要配置环境变量.bashrc如下
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/linux/anaconda3/envs/tf2.10_py3.8/lib
问题2
WARNING conda.models.version:get_matcher(548): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.7.1., but conda is ignoring the . and treating it as 1.7.1
Ubuntu 20.04
conda create -n tf1.13_py3.6 python=3.6
conda activate tf1.13_py3.6
pip install tensorflow-gpu==1.13.1
conda install cudatoolkit=10.0 cudnn