1.配置下载源(国内)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --set show_channel_urls yes
2.tensorflow-gpu
conda create -n tf2 tensorflow-gpu
conda activate tf2
3.TensorFlow运行显存占用模式设置
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:# 设置 GPU 为增长式占用
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
print('succeed')
except RuntimeError as e:
# 打印异常
print(e)