东方耀AI技术分享

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 2902|回复: 0
打印 上一主题 下一主题

[课堂笔记] win10 64位完美成功安装tensorflow-gpu和pytorch

[复制链接]

1365

主题

1856

帖子

1万

积分

管理员

Rank: 10Rank: 10Rank: 10

积分
14429
QQ
跳转到指定楼层
楼主
发表于 2020-10-13 17:43:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
win10 64位完美成功安装tensorflow-gpu和pytorch




win10上已成功安装了:
系统:win10 64位
显卡:GeForce RTX 2080 Ti  11G
CUDA:v10.2
cuDNN:v7.6.5
Python:3.6.10
TensorFlow-GPU:1.15
PyTorch :  1.6.0

Visual C++ Build tools: 2019


pytorch安装(由于系统已经安装了cuda10.2所以直接用pip3):
pip3 install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html


测试成功:T.cuda.is_available()




先pip3 install tensorflow-gpu==1.15尝试:
tensorflow-gpu            1.15.0                   pypi_0    pypi




pip3方式安装tf1.15 gpu版本最多支持cuda10.0


Could not load dynamic library 'cudart64_100.dll'


测试失败:tf.test.is_gpu_available()




为了使用tf-gpu只能先用pip3卸载 然后用conda 进行install
pip3 uninstall tensorflow-gpu==1.15
pip3 uninstall tensorboard
pip3 uninstall tensorflow-estimator




conda install tensorflow-gpu==1.15
这样conda会帮我们下载对应的cuda cudnn 还有其他的很多依赖
cudatoolkit        pkgs/main/win-64::cudatoolkit-10.0.130-0
  cudnn              pkgs/main/win-64::cudnn-7.6.5-cuda10.0_0


这样就对了!


测试就成功啦:tf.test.is_gpu_available()



冲突了报错:
>>> import tensorflow as tf
2020-10-13 17:59:43.246234: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
D:\Miniconda3\envs\py3_tf1_torch\lib\site-packages\h5py\__init__.py:40: UserWarning: h5py is running against HDF5 1.10.5 when it was built against 1.10.4, this may cause p
roblems
  '{0}.{1}.{2}'.format(*version.hdf5_built_version_tuple)
Warning! ***HDF5 library version mismatched error***


由于conda安装tf依赖太多,所以调整一下顺序,先来安装tf-gpu 就应该可以避免冲突
conda remove -n py3_tf1_torch --all
conda create -n py3_tf1_torch python==3.6.10
conda activate py3_tf1_torch


conda install tensorflow-gpu==1.15

tf.test.is_gpu_available() 终于成功了 也不冲突了

pip3 install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

测试成功:T.cuda.is_available()



win10 pytorch 编译cuda 10.2 Visual C++ Build tools


Microsoft Visual C++ Build Tools 2015 这个版本还不行 很多c++的语法错误


想安装最全最完整最新的vc++运行库,莫非用Visual Studio安装了,这是Microsoft官方出品的,但是安装要安装整个vs,非常的麻烦

直接安装 Visual C++ Build tools 即可




error: a member with an in-class initializer must be const

D:/Miniconda3/envs/py3_tf1_torch/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(483): error: a member with an in-class initializer must be const

D:/Miniconda3/envs/py3_tf1_torch/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(496): error: a member with an in-class initializer must be const

D:/Miniconda3/envs/py3_tf1_torch/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(510): error: a member with an in-class initializer must be const

D:/Miniconda3/envs/py3_tf1_torch/lib/site-packages/torch/include\torch/csrc/jit/api/module.h(523): error: a member with an in-class initializer must be const


在static后面加const即可
static const CONSTEXPR_EXCEPT_WIN_CUDA bool all_slots = false;


编译*.cu和*.cpp文件:
cuda10.2的nvcc.exe
visual studio 2019 build tools

又来报错:
focal_loss_cuda.obj : error LNK2001: 无法解析的外部符号 "public: long __cdecl at::Tensor::item<long>(void)const " (??$item@J@Tensor@at@@QEBAJXZ)
build\lib.win-amd64-3.6\mmdet\cv_core\_ext.cp36-win_amd64.pyd : fatal error LNK1120: 1 个无法解析的外部命令
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120























tf1.15支持cuda10.0.png (86 KB, 下载次数: 125)

tf1.15支持cuda10.0.png

cuda10.2.png (11.52 KB, 下载次数: 124)

cuda10.2.png

vs2019build_tools.png (33.23 KB, 下载次数: 124)

vs2019build_tools.png

vs2019_cuda10.2.png (105.13 KB, 下载次数: 125)

vs2019_cuda10.2.png
让天下人人学会人工智能!人工智能的前景一片大好!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|人工智能工程师的摇篮 ( 湘ICP备2020019608号-1 )

GMT+8, 2024-4-20 03:37 , Processed in 0.179745 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表