基本环境
nvidia-smi
安装过程(conda环境)
# 新建环境
conda activate -n tf2 python=3.8
# 启动环境
conda activate tf2
# 安装cudatoolkit
conda install cudatoolkit=11.0
# 安装cudann
conda install -c anaconda cudnn
# 安装tensorflow
pip install tensorflow-gpu==2.6.0
出现的问题1:
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
解决方案:
pip install protobuf==3.20.*
出现问题2:
找不到libcudnn.so.8
W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
解决方案(不设置全局,不用管理员账号的方法)
# 找到 libcudnn.so.8
locate libcudnn.so.8
# 复制到当前环境下的lib和include文件夹下
cp /路径/路径到libcudnn.so.8 home/用户名/anaconda/envs/tf2/lib
cp /路径/路径到libcudnn.so.8 home/用户名/anaconda/envs/tf2/include