|
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
|
|