Gur*_*uku 21 python gpu tensorflow
如何在Python 3.6 x64中使用TensorFlow GPU版本而不是CPU版本?
import tensorflow as tf
Run Code Online (Sandbox Code Playgroud)
Python正在使用我的CPU进行计算.
我可以注意到它,因为我有一个错误:
您的CPU支持未编译此TensorFlow二进制文件的指令:AVX2
我已经安装了tensorflow和tensorflow-gpu.
如何切换到GPU版本?
小智 25
遵循本教程Tensorflow GPU,我做到了,它运行完美。
注意!-安装9.0版!Tensorflow-gpu不支持较新的版本
脚步:
pip install tensorflow-gpufrom tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
如果您有 Nvidia,安装 tensorflow GPU 的“新”方法是使用Anaconda。也适用于 Windows。带 1 行。
conda create --name tf_gpu tensorflow-gpu
Run Code Online (Sandbox Code Playgroud)
这是 3 个命令的快捷方式,如果需要,或者如果您已经有 conda 环境并且不需要创建一个,您可以单独执行它们。
创建anaconda环境 conda create --name tf_gpu
激活环境 conda activate tf_gpu
安装 tensorflow-GPU conda install tensorflow-gpu
您可以使用 conda 环境。
按照最新版本的文档中的步骤操作。注意:GPU 和 CPU 功能现在合并在一个 tensorflow 包中
pip install tensorflow
# OLDER VERSIONS pip install tensorflow-gpu
Run Code Online (Sandbox Code Playgroud)
https://www.tensorflow.org/install/gpu
如果需要,这是安装驱动程序和 CUDA 的绝佳指南:https : //www.quantstart.com/articles/installing-tensorflow-22-on-ubuntu-1804-with-an-nvidia-gpu/
| 归档时间: |
|
| 查看次数: |
59569 次 |
| 最近记录: |