如何使用软件实现在没有 GPU 的情况下运行 CUDA?
我的笔记本电脑没有 nVidia 显卡,我想在 CUDA 上工作。该网站称 CUDA 也可以在非 cuda 硬件上以仿真模式使用。但是,当我尝试安装从其网站下载的 CUDA 驱动程序时,出现错误“nvidia 安装程序无法找到与您当前硬件兼容的任何驱动程序。安装程序现在将退出”。
另外,当我尝试在 Visual Studio 2008 中运行 SDK 中的示例代码时,我收到一条错误,指出未找到 .obj 文件。
My laptop doesn't have a nVidia graphic cards, and I want to work on CUDA. The website says that CUDA can be used in emulation mode on non-cuda hardware too. But when I tried installing CUDA drivers downloaded from their website, it gives an error "The nvidia setup couldn't locate any drivers that are compatible with your current hardware. Setup will now exit".
Also when I tried to run sample codes from SDK in Visual studio 2008, I'm getting an error that .obj file is not found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
开始 GPU 开发的最简单方法是购买一个便宜的(例如 GTX285)GPU 和一台台式计算机(显然,因为您无法更改笔记本电脑中的 GPU)。
有一些研究项目致力于让 CUDA 内核在 CPU 和 FPGA 上高效工作(Google wen mei hwu 并查看他的研究项目)但是,如果您想学习 CUDA,这不适合您,如上所述,最简单的方法是获得一些便宜的硬件。
The easiest way to get started with GPU development is to get a cheap (for example GTX285) GPU and a desktop computer (obviously since u can't change the GPU in your laptop).
There are a few research projects on getting CUDA kernels to work efficiently on CPUs as well as on FPGAs (Google wen mei hwu and see his research projects) however if you want to learn CUDA this is not for you, as said above the easiest way is to get some cheap hardware.
你下载了CUDA工具包了吗?您需要下载工具包(包括编译器和运行时库)和 SDK。当您构建 SDK 示例时,请务必将配置更改为“EmuDebug”或“EmuRelease”。
Have you downloaded the CUDA toolkit? You'll need to download the toolkit (which includes the compiler and the runtime library) and the SDK. When you are building the SDK samples be sure to change the configuration to "EmuDebug" or "EmuRelease".
现在我们有了OpenCL。它几乎适用于您拥有的所有硬件:CPU、GPU(nvidia 或 amd)、APU、FPGA 等
(我到达此处在非 nvidia 硬件中搜索 CUDA 编译 - 出于与 OpenCL 进行比较的目的 - 但显然它仍然适用于仅限英伟达:/)。
Nowadays we have OpenCL. It's works on almost every hardware you can have: CPUs, GPUs (nvidia or amd), APUs, FPGAs etc.
(I reached here searching for CUDA compilation in a non nvidia hardware - for comparison purposes with OpenCL - but apparently it's still works on nvidia only. Sad :/).
我知道这已经太晚了,但您实际上可以在 Google Colab 上运行
CUDA
!习惯和设置需要 2 分钟,但它工作得很好,几乎与您在自己的机器上的操作完全一样,而且如果您只是想练习的话,它相当便宜!我在 GitHub 存储库中发布了一个笔记本,向您展示如何设置它: https://github.com /notY0rick/cuda_practiceI know this is super late, but you can actually run
CUDA
on Google Colab! It takes 2 minutes to get used to and set up, but it works decently well and almost exactly like how you would on your own machine, and it's pretty cheap if you're just trying to practice! I posted a notebook in my GitHub repo here to show you how you can set it up: https://github.com/notY0rick/cuda_practice截至 2024 年,至少还有两个有效选项可以在没有 nvidia GPU 的情况下运行 cuda 代码。
chipStar 使用 OpenCL 或 Intel OneApi 的零级编译 CUDA 和 HIP 代码。设置完成后,它会提供 cuspvc,或多或少是 cuda 编译器的替代品。编译 cuda 文件就像
cuspvc 示例.cu -o 示例
的组合HIPIFY 和 HIP-CPU 可以先将您的 cuda 代码转换为 HIP 代码,然后可以为任何CPU编译。一旦两者都设置完毕,编译 cuda 文件的两个步骤如下所示:
hipify-clang example.cu --hip-kernel-execution-syntax -o example.cpp
g++ example.cpp -ltbb -o 示例
我在一个简单的 saxpy cuda 示例中成功测试了两者。
As of 2024, there are at least two more valid options to run cuda code without nvidia GPUs.
chipStar compiles CUDA and HIP code using OpenCL or level zero from Intels OneApi. Once setup it provides
cuspvc
, a more or less drop in replacement for the cuda compiler. Compiling a cuda file goes likecuspvc example.cu -o example
A combination of HIPIFY and HIP-CPU can first convert your cuda code to HIP code which then can be compiled for any CPU. Once both are setup, the two steps to compile a cuda file look something like:
hipify-clang example.cu --hip-kernel-execution-syntax -o example.cpp
g++ example.cpp -ltbb -o example
I tested both successfully for a simple saxpy cuda example.