[英]How to install Tensorflow properly on Windows using Python?
I'm trying to use tensorflow with my PC's GPU (Nvidia RTX 3070Ti) in python-conda environment.我正在尝试在 python-conda 环境中将 tensorflow 与我的 PC GPU(Nvidia RTX 3070Ti)一起使用。 I'm solving a small image-classification problem from kaggle.
我正在解决来自 kaggle 的一个小图像分类问题。 I've solved it in google-collab, but now I'm intrested in solving it on my local machine.
我已经在 google-collab 中解决了它,但现在我有兴趣在我的本地机器上解决它。 However TF doesn't work properly locally and I have no idea why.
但是 TF 在本地无法正常工作,我不知道为什么。 I've read tons of solutions but it didn't help yet.
我已经阅读了大量的解决方案,但还没有帮助。
I'm following this guide and always install proper versions of TF and CUDA: https://www.tensorflow.org/install/source_windows我遵循本指南并始终安装正确版本的 TF 和 CUDA: https://www.tensorflow.org/install/source_windows
cuda-toolkit 10.1, cudnn 7.6, tf-gpu 2.3, python 3.8 cuda-toolkit 10.1, cudnn 7.6, tf-gpu 2.3, python 3.8
Also I've installed latest NVidia drivers for videocard.我还为视频卡安装了最新的 NVidia 驱动程序。
What I've tried:我试过的:
Result: TF can't find my GPU and uses only CPU.结果: TF 找不到我的 GPU 并且只使用 CPU。
Result: TF recognizes my GPU and uses it: But during DNN training happens error: Failed to launch ptxas Relying on driver to perform ptx compilation. Modify $PATH to customize ptxas location.
结果: TF 识别出我的 GPU 并使用它: 但是在 DNN 训练期间发生错误:
Failed to launch ptxas Relying on driver to perform ptx compilation. Modify $PATH to customize ptxas location.
Failed to launch ptxas Relying on driver to perform ptx compilation. Modify $PATH to customize ptxas location.
And training goes very bad - accuracy is very low and doesn't improving.训练非常糟糕——准确性非常低而且没有提高。
When I use absolutely same code and data on google-collab, everything is going smoothly - I get ~90% accuracy on 5th epoch.当我在 google-collab 上使用完全相同的代码和数据时,一切都进行得很顺利——我在第 5 个 epoch 上获得了大约 90% 的准确率。
I've tried tf 2.1 and relevant cuda and cudnn, but it's still same result!我试过 tf 2.1 和相关的 cuda 和 cudnn,但结果仍然相同!
I've tried to install cudatoolkit-dev, but it didn't help to solve ptxas problem.我尝试安装 cudatoolkit-dev,但它并没有帮助解决 ptxas 问题。
I'm about to give up and use PyTorch instead of Tensorflow.我即将放弃并使用 PyTorch 而不是 Tensorflow。
So here is what worked for me:所以这对我有用:
conda install -c esri cudatoolkit conda install -c esri cudnn conda install -c esri tensorflow-gpu
conda install -c conda-forge tensorflow-hub
It will downgrade installations from previous steps, but it works.它会从之前的步骤中降级安装,但它可以工作。 Maybe installing tensorflow-hub first could help to avoid it, but I didn't test it.
也许首先安装 tensorflow-hub 可以帮助避免它,但我没有测试它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.