tensorflow2.6.0配置

安装

创建环境

可以先通过 nvidia-smi 查看最高能支持的cuda版本
conda env list 用于查看所有的虚拟环境
conda create -n tf26 python==3.9 (记得查看对应版本的python
activate tf26 激发tensorflow虚拟环境
pip list 查看tensorflow版本

安装tensorflow2.6.0

pip install tensorflow==2.6.0

下载cudatool,cudnn

找版本


https://tensorflow.google.cn/install/source_windows?hl=en#gpu
cudatool11.2.2下载地址:https://developer.nvidia.com/cuda-11.2.2-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
cudnn8.1下载地址: https://developer.nvidia.com/rdp/cudnn-archive

cuda安装




注意,如果vs版本跟cuda版本不符合会安不上,所以要把vs卸掉

cudnn

只需要将下载下来的压缩包解压后,将对应文件夹的文件放到CUDA安装路径下的对应文件夹里即可

gpu版本下载

pip install tensorflow-gpu==2.6.0

keras下载

pip install keras==2.6.0

torch下载

因为官网没有对应的,所以通过命令行下载

conda install pytorch==1.8.0 torchvision==0.9.0

检查

import torch
print('CUDA版本:',torch.version.cuda)
print('Pytorch版本:',torch.__version__)
print('显卡是否可用:','可用' if(torch.cuda.is_available()) else '不可用')
print('显卡数量:',torch.cuda.device_count())
print('当前显卡型号(返回gpu名字,设备索引默认从0开始):',torch.cuda.get_device_name())
print('当前设备索引:',torch.cuda.current_device())
print('当前显卡的CUDA算力:',torch.cuda.get_device_capability())
from torch.backends import cudnn
print('cuddn是否可用:',cudnn.is_available())

在jupyter中切换虚拟环境

首先,进入prompt,切换到你的虚拟环境

然后,安装ipykernel

conda install ipykernel

最后,将你的虚拟环境加入到ipykernel中

python -m ipykernel install --name 你的虚拟环境的名字
python -m ipykernel install --name tf260
posted @ 2022-09-25 20:03  Tongzhai  阅读(447)  评论(0)    收藏  举报