注:博客内容具有时效性,笔者安装时使用conda search tensorflow-gpu没有找到对应依赖numpy版本在1.20以下的,故采用本博客中提到的方法。仍建议不要同时使用pypi和conda进行package的管理。
创建一个带有python的虚拟环境:
conda create -n tf2.6 python=3.8
激活虚拟环境:
conda activate tf2.6
使用pypi安装tensorflow-gpu==2.6:
pip install tensorflow-gpu==2.6 --user
【pypi会自动安装numpy==1.19.5和scipy==1.6.2;conda中多为numpy==1.21和scipy==1.7存在版本冲突】
安装cuda:
conda install cudatoolkit=11.3
安装cudnn:
conda install cudnn=8.2
【如果想使用keras可以直接from tensorflow import keras】
【以下为个人笔记,无需参考】
base
conda install nb_conda
tf2.6
conda install cudatoolkit=11.3 conda install cudnn=8.2 conda install -y jupyter pip install -r requirements.txt --user pip install -q git+https://github.com/tensorflow/docs
requirements.txt
tensorflow-gpu==2.6 opencv-python==4.5.3 pandas==1.3.3 matplotlib==3.4.3 imageio==2.9.0 imutils==0.5.4 tqdm==4.62.3



