【发布时间】:2022-07-15 17:14:19
【问题描述】:
我想在 GPU 上使用并行化测试运行一些有限差分时域 (FDTD) 模拟,并将速度与基于 CPU 的模拟运行进行比较。这基本上是我第一次尝试使用 GPU 加速进行科学计算。
我的系统配置:
CPU: Intel Core i7-4930K @ 3.40 GHz
GPU: Gigabte GeForce GTX 1650 OC LP 4.0 GB
RAM: 32.0 GB (16.0 GB usable)
OS: Windows 7 Home Premium 64-bit
此 GPU 具有 896 CUDA cores 和 compute capability 7.5,因此与在“仅”12 个 CPU 内核上运行我的模拟相比,我预计会有显着的加速。
模拟脚本使用fdtd 模拟包,为方便起见,我使用 Jupyter 笔记本。如果您对一些实际的代码参考感兴趣,我建议您查看fdtd GitHub 页面上的简短示例脚本。
我已经安装了 CUDA ToolKit 版本 10.2,因为这似乎是最后一个支持 Windows 7 的版本。版本 11.0+ 似乎仅支持 Windows 10+,至少根据 download page(有人可以确认吗?)。
我还安装了torch + torchvision + torchaudio,只是因为在安装过程中PyTorch includes these packages。但是,我在尝试安装 Python CUDA ToolKit 时遇到了问题,因为它是 seems to require 另一个名为 nvidia-pyindex、which is not available for Windows 的软件包。此外,我对 CUDA 10.2 的 PyTorch 安装命令感到困惑,上面写着 "CUDA-10.2 PyTorch builds are no longer available for Windows, please use CUDA-11.6",尤其是因为他们 clearly state:
支持的 Windows 发行版
以下 Windows 发行版支持 PyTorch:
Windows 7 及更高版本;建议使用 Windows 10 或更高版本。 Windows Server 2008 r2 及更高版本
在 Python 解释器中,我得到了
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
并尝试在模拟包中设置 CUDA 后端返回
import fdtd
fdtd.set_backend("torch.cuda.float64")
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [3], in <cell line: 35>()
31 display(HTML("<style>.container {width:100% !important;}</style>"))
33 #fdtd.set_backend("numpy")
34 #fdtd.set_backend("torch.float64")
---> 35 fdtd.set_backend("torch.cuda.float64")
File C:\Program Files\Python38\lib\site-packages\fdtd\backend.py:376, in set_backend(name)
374 raise RuntimeError("Torch backend is not available. Is PyTorch installed?")
375 if name.startswith("torch.cuda") and not TORCH_CUDA_AVAILABLE:
--> 376 raise RuntimeError(
377 "Torch cuda backend is not available.\n"
378 "Do you have a GPU on your computer?\n"
379 "Is PyTorch with cuda support installed?"
380 )
382 if name.count(".") == 0:
383 dtype, device = "float64", "cpu"
RuntimeError: Torch cuda backend is not available.
Do you have a GPU on your computer?
Is PyTorch with cuda support installed?
我应该如何从这里进步?
注意:问题已结束,建议将其发布到其他地方,但在 Computational Science SE 上,人们建议将其发布到此处。
【问题讨论】:
标签: python cuda gpu nvidia pycuda