![](/img/trans.png)
[英]How to install tensorflow 2 gpu on windows 10 with conda?
[英]How to make code run on GPU on Windows 10?
我想在 windows 10 中运行我的代码在 gpu 上运行,就像对于 google colab 一样,我们可以更改运行时选项,这很容易转移到 gpu。是否有可能对 windows 中的 jupyter notebook 执行相同的操作。
您实际上需要使用 tensorflow-gpu 在 gpu 上运行您的 jupyter notebook。
实现这一目标的最佳方法是
在您的系统上安装Anaconda
下载cuDNN和Cuda 工具包 11.3 。
将 cuDNN 和 Cuda 工具包添加到您的 PATH。
在 Anaconda 中创建环境
pip 安装tensorflow-gpu
pip 安装 [jupyter-notebook/jupyterlab]
在笔记本中导入 tensorflow-gpu
享受。 您现在可以在 GPU 上运行您的笔记本
打开 Anaconda 推广并写入
现在是时候测试我们的代码是否在 GPU 或 CPU 上运行
Conda 激活 tf_GPU ---(激活环境)
Jupyter 笔记本 ----(从 tf_GPU 环境打开笔记本)
如果这段代码给你 1 这意味着你正在运行 GPU
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
您还可以使用此代码来确保您在 GPU 上运行
tf.debugging.set_log_device_placement(True)
# Create some tensors
a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
c = tf.matmul(a, b)
print(c)
像这样获得 output 意味着您使用的是 CPU 而不是 GPU
Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:CPU:0
Executing op _EagerConst in device /job:localhost/replica:0/task:0/device:CPU:0
Executing op MatMul in device /job:localhost/replica:0/task:0/device:CPU:0
tf.Tensor(
[[22. 28.]
[49. 64.]], shape=(2, 2), dtype=float32)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.